要求:
重写所有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.

解决方案 »

  1.   

    RewriteCond %{QUERY_STRING}% ^more=(*)$ 后面部分应分正则表达式,即more存在,则条件符合
    你那样写显然不符合或以试试这个
    RewriteCond %{QUERY_STRING}% .*?more=([0-9]+).*?
      

  2.   

    建议你去http://www.seowhy.com 上看一看,还有正则表达式要稍微了解,
    推荐一本书《搜索引擎优化高级编程(PHP版)》
      

  3.   

    seowhy和这本书,我之前都有看过,是不错的
      

  4.   

    重写实现了,但即便存在真实的URL也重写怎么做呢?
    这是不是跟服务器的全局配置有关呢!!!
      

  5.   

    重写实现了,但即便存在真实的URL也重写怎么做呢? 当然是重写优先了,因为它是服务器级的另外,注意不要死循环
      

  6.   

    <IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase / RewriteCond %{QUERY_STRING} (.*more.*)
    RewriteRule test\.html$ /test.php?%1 [L]</IfModule> 
    这个重写规则是test.html结尾的 重定向/test.php?... 但是前提是query_string要含more这个字.你试试吧.
      

  7.   

    有的是虚拟机,自己只有修改.htaccess的权限!!!
      

  8.   

    只有这个顺序重写,其它不重写:
    RewriteRule test.html\?(more)=(*)&(other)=(*)$ test.php?$3=$4&$1=$2
      

  9.   

    但即便存在真实的URL也重写怎么做呢?
    什么意思?
      

  10.   

    比如:
    访问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,这是为什么呢?是不是重写有什么优先级呢?