[英]Issues with mod_rewrite
I have a problem with mod_rewrite. 我对mod_rewrite有问题。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1.php [L,QSA]
RewriteRule ^article/(.+)$ /article.php?article=$1
This is my .htaccess. 这是我的.htaccess。 With the first rewrite_rule, I hide the file extensions.
在第一个rewrite_rule中,我隐藏了文件扩展名。 It works without a problem.
它可以正常工作。 With the second rule, I like to turn "article.php?article=Example" into "article/Example".
使用第二条规则,我想将“ article.php?article = Example”变成“ article / Example”。 But whenever I try to visit the page via "article/Example" I get an 500 Internal Server Error.
但是每当我尝试通过“文章/示例”访问页面时,都会收到500 Internal Server Error。 The first rule works fine and I can also access the page using article.php?article=Example.
第一条规则很好用,我也可以使用article.php?article = Example访问该页面。
Reverse the order of your rules and use MultiViews
to disable content negotiation: 颠倒规则的顺序,并使用
MultiViews
禁用内容协商:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule ^article/(.+)$ /article.php?article=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1.php [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.