要求:
重写所有QUERY_STRING中包括有more=XX的url请求,即使真实url存在!!比如存在test.html文件
http://abc.com/test.html?more=1&other=0
http://abc.com/test.html?other=0&more=1
重写为:
http://abc.com/test.php?other=0&more=1像http://abc.com/test.html?other=0&u=456这样的就不重写<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /RewriteCond %{QUERY_STRING}% ^more=(*)$
RewiteRule ^?(.*)$ /test.php?more=$1 [L]</IfModule>
我上面的错在哪呢?错误提示:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
重写所有QUERY_STRING中包括有more=XX的url请求,即使真实url存在!!比如存在test.html文件
http://abc.com/test.html?more=1&other=0
http://abc.com/test.html?other=0&more=1
重写为:
http://abc.com/test.php?other=0&more=1像http://abc.com/test.html?other=0&u=456这样的就不重写<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /RewriteCond %{QUERY_STRING}% ^more=(*)$
RewiteRule ^?(.*)$ /test.php?more=$1 [L]</IfModule>
我上面的错在哪呢?错误提示:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
你那样写显然不符合或以试试这个
RewriteCond %{QUERY_STRING}% .*?more=([0-9]+).*?
推荐一本书《搜索引擎优化高级编程(PHP版)》
这是不是跟服务器的全局配置有关呢!!!
RewriteEngine On
RewriteBase / RewriteCond %{QUERY_STRING} (.*more.*)
RewriteRule test\.html$ /test.php?%1 [L]</IfModule>
这个重写规则是test.html结尾的 重定向/test.php?... 但是前提是query_string要含more这个字.你试试吧.
RewriteRule test.html\?(more)=(*)&(other)=(*)$ test.php?$3=$4&$1=$2
什么意思?
访问1 http://abc.com/test/123.html
在abc.com的web服务的test目录下有123.html这个文件,即我说的存在真实的URL。访问2 http://abc.com/test/123.html?more=1
即便存在123.html时,query_string为more=1就重写到http://abc.com/test/123.php现在我的问题是,若不存在123.html“访问2”的重写可以实现,但若存在123.html则无法实现重写,访问的还是123.html,这是为什么呢?是不是重写有什么优先级呢?