[英]htaccess URL Rewrite Not working with first rule
I have the following rules setup for my blog and they seem to work just fine. 我为我的博客设置了以下规则,它们似乎正常工作。
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(index\.php|(modules|css|files|fonts|ico|img|js)/)
RewriteRule ^([^/]*)/page/([^/]*)$ /framework/?p=$1&page=$2 [L]
RewriteRule ^([^/]*)/search/([^/]*)$ /framework/?p=$1&search=$2 [L]
RewriteRule ^([^/]*)/search/([^/]*)/page/([^/]*)$ /framework/?p=$1&search=$2&page=$3 [L]
So I was feeling confident and wanted to add one more rule for the just the basic page. 因此,我感到有信心,并想为基本页面添加更多规则。
so I added this rule 所以我增加了这个规则
RewriteRule ^([^/]*)$ /framework/?p=$1 [L]
so that my htaccess file now looks like this 这样我的htaccess文件现在看起来像这样
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(index\.php|(modules|css|files|fonts|ico|img|js)/)
RewriteRule ^([^/]*)$ /framework/?p=$1 [L]
RewriteRule ^([^/]*)/page/([^/]*)$ /framework/?p=$1&page=$2 [L]
RewriteRule ^([^/]*)/search/([^/]*)$ /framework/?p=$1&search=$2 [L]
RewriteRule ^([^/]*)/search/([^/]*)/page/([^/]*)$ /framework/?p=$1&search=$2&page=$3 [L]
but for if I go to http://www.example.com/framework/blog
I get a 500 Internal Server Error
if I take out the line and go to http://www.example.com/framework/blog/page/2
it loads my second page without any issues. 但是,如果我转到
http://www.example.com/framework/blog
如果我删除该行并转到http://www.example.com/framework/blog/page/2
则会收到500 Internal Server Error
http://www.example.com/framework/blog/page/2
它加载我的第二页,没有任何问题。
I am not sure what I am doing wrong? 我不确定自己在做什么错? Any advice would be appreciated.
任何意见,将不胜感激。
You can use: 您可以使用:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /framework/
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^([^/]+)/page/([^/]*)$ ?p=$1&page=$2 [L,QSA]
RewriteRule ^([^/]+)/search/([^/]*)/page/([^/]*)$ ?p=$1&search=$2&page=$3 [L,QSA]
RewriteRule ^([^/]+)/search/([^/]*)$ ?p=$1&search=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ ?p=$1 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.