View Full Version : mod_rewrite
Rapid Dr3am
07-28-04, 06:45 AM
Hello,
I'm having some problems with mod_rewrite.
My code is this:
RewriteEngine on
RewriteBase /
RewriteRule ^index.php?page=(.*)$ index.php?page=$1
RewriteRule ^(.*).php$ index.php?page=$1
I can load file.php and get what I got at index.php?page=page but I can't load index.php?page=page anymore it returns to index.php like $_GET isn't working anymore.
JasonMichael
07-30-04, 12:57 PM
For one thing, you're missing a CRUCIAL part of the command string..
You need an [L] at the end of your last line...
and then you need [QSA] on the end of the lines above..I'M just guessing right now that this is all you need to fix your problem though... but give it a try:
RewriteEngine on
RewriteBase /
RewriteRule ^index.php?page=(.*)$ index.php?page=$1 [QSA]
RewriteRule ^(.*).php$ index.php?page=$1[L]
here's a reference link to apache mod_rewrite: http://www.apacheref.com/ref/mod_rewrite/RewriteRule.html
Also here's a site/forum posting on the topic to check out: READ THE LAST ITEM POSTED - the guy ended up solving his own problem:
http://www.webmasterworld.com/forum92/1431-2-10.htm
As far as $_GET not working, I almost wonder if depending on how you rewrite your url, you may be getting rid of the $_GET variables in the URL,eh?
You may have to get your variable values from the Path Info of the URL....
for example, you could have a URL of:
http://www.jmrtechnet.com/index.php/article/16
Then use some PHP code to get your vars:
$pathInfo = explode("/", $_SERVER['PATH_INFO']);
Hope this helps
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.