Fixago
08-21-2006, 02:15 AM
Hm. Ok, I really didn't know where this should go, in programming, in technical issues, or where, so I'm putting it here unless the mods think it should go somewhere else.
First thing's first. I hate mod_rewrite, only because it baffles me. I'm trying to do something similar to what Wordpress does with the rewriting of their URLs, so this is not something simple like redirecting an old page to a new one, I understand that jazz.
Anyways, here's the scenario. I have over 50 articles that are stored in a database, and right now I'm pulling them like so:domain.com/article/index.php?id=68The database has three fields: id, title, content
Do I need to have mod_rewrite interact with the PHP script for rewriting, or how does this work? I can't seem to find a good tutorial on advanced mod_rewrite, maybe someone here has a good link.
Anyways, here's what I want to happen. I want the URL to rewrite itself by pulling the information in the title field based on the id and output the URL as:domain.com/article/this-is-the-title-right-hereObviously stripping out special characters like — and punctuation like question marks and commas.
I would prefer a push in the right direction, and not a here is the answer. Make me work for it :D Thanks guys!
Oh, and I've been looking at an example of an .htaccess from vBSEO (modified because I was playing around with the URLs), and it looks something like this, and I just know the answer is in here somewhere, but it's confusing me:
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} (article|print|book)/
RewriteRule ^(.*)$ $1 [L]
RewriteCond %{QUERY_STRING} !id=
RewriteRule ^(.*\.php)$ index.php?id=$1&%{QUERY_STRING} [L]
RewriteRule ^(article/.*)$ index.php?id=$1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?id=$1&%{QUERY_STRING} [L]So I know I have to use the REQUEST_FILENAME, QUERY_STRING, and some regex...and I guess another part of my question is, how is this interacting, or what is it interacting with, are these variables somehow being passed through a PHP script?! Agh, head hurts. Thanks!
First thing's first. I hate mod_rewrite, only because it baffles me. I'm trying to do something similar to what Wordpress does with the rewriting of their URLs, so this is not something simple like redirecting an old page to a new one, I understand that jazz.
Anyways, here's the scenario. I have over 50 articles that are stored in a database, and right now I'm pulling them like so:domain.com/article/index.php?id=68The database has three fields: id, title, content
Do I need to have mod_rewrite interact with the PHP script for rewriting, or how does this work? I can't seem to find a good tutorial on advanced mod_rewrite, maybe someone here has a good link.
Anyways, here's what I want to happen. I want the URL to rewrite itself by pulling the information in the title field based on the id and output the URL as:domain.com/article/this-is-the-title-right-hereObviously stripping out special characters like — and punctuation like question marks and commas.
I would prefer a push in the right direction, and not a here is the answer. Make me work for it :D Thanks guys!
Oh, and I've been looking at an example of an .htaccess from vBSEO (modified because I was playing around with the URLs), and it looks something like this, and I just know the answer is in here somewhere, but it's confusing me:
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} (article|print|book)/
RewriteRule ^(.*)$ $1 [L]
RewriteCond %{QUERY_STRING} !id=
RewriteRule ^(.*\.php)$ index.php?id=$1&%{QUERY_STRING} [L]
RewriteRule ^(article/.*)$ index.php?id=$1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?id=$1&%{QUERY_STRING} [L]So I know I have to use the REQUEST_FILENAME, QUERY_STRING, and some regex...and I guess another part of my question is, how is this interacting, or what is it interacting with, are these variables somehow being passed through a PHP script?! Agh, head hurts. Thanks!
