requests -----> should be开发者_运维百科 written to new url
/institute/dps -----> /institute.php?slug=dps
/institute/abc -----> /institute.php?slug=abc /institute/123 -----> /institute.php?slug=123I am using following rule in .htaccess
RewriteRule ^institute/(.*)$ /institute.php?slug=$1However, it's not working. the page insitute.php get's execution, but the query string always comes empty.
Any suggestions?
That should work... If you try
RewriteRule ^institute/(.*)$ /institute.php?slug=$1 [R]
it should redirect formally, and you'll see the new URI
If you don't have the [R] in there it will issue the correct request, but you won't see ?slug=
in the query string, but $_REQUEST['slug']
will be set.
Have you turned on Rewriting in your .htaccess file? (before your RewriteRule)
RewriteEngine On
If so - does your apache configuration allow you to use .htaccess file? (look for the line)
AllowOverride None
inside you httpd.conf it SHOULD be
AllowOverride All
Finally make sure the url rewriting module is turned on in httpd.conf (it might be commented out)
LoadModule rewrite_module modules/mod_rewrite.so
精彩评论