开发者

Apache url rewrite problem

开发者 https://www.devze.com 2022-12-24 05:44 出处:网络
requests----->should be开发者_运维百科 written to new url /institute/dps----->/institute.php?slug=dps

requests -----> should be开发者_运维百科 written to new url

/institute/dps -----> /institute.php?slug=dps

/institute/abc -----> /institute.php?slug=abc

/institute/123 -----> /institute.php?slug=123

I am using following rule in .htaccess

RewriteRule ^institute/(.*)$ /institute.php?slug=$1

However, 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

0

精彩评论

暂无评论...
验证码 换一张
取 消