Page 1 of 1

php, mysql, mod_rewrite

Posted: Wed Jan 06, 2010 4:20 pm
by daande
So lets say I would like to make a pretty url to have site.com/123 instead of site.com/index.php?i=123. I have the code to do this and it works. However, when you enter site.com/123 it goes to the page but the url in the address bar of the browser changes to site.com/index.php?i=123 instead of remaining at site.com/123. Does anyone know if it is possible to keep it as site.com/123 after the redirect?

Re: php, mysql, mod_rewrite

Posted: Wed Jan 06, 2010 4:32 pm
by Christopher
Post "the code to do this" (rewrite rules?) and perhaps someone can help.

Re: php, mysql, mod_rewrite

Posted: Wed Jan 06, 2010 4:36 pm
by daande
Here is the .htaccess file:

Code: Select all

 
RewriteEngine On
RewriteRule ^([A-Za-z0-9-]+)/?$ http://site.com/getimage.php?i=$1 [L]
 

Re: php, mysql, mod_rewrite

Posted: Wed Jan 06, 2010 5:54 pm
by requinix
By including the "http://site.com/" you're telling mod_rewrite to do an external redirect.
If you want everything to remain internal, get rid of it.

Re: php, mysql, mod_rewrite

Posted: Wed Jan 06, 2010 6:37 pm
by daande
Problem fixed. Thank you very much!