以下是我的.htaccess文件中的内容:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^$\ [NC]
RewriteRule . ?%{REQUEST_URI} [QSA,L]
最后三行将example.com/之后的所有内容转换为GET,因此example.com/blahblah将成为example.com/?blahblah。
我的问题是,当%3A%2F%2F
位于网址中时,会导致404错误。例如:example.com/blah=http%3A%2F%2Fwww.test.com
将导致404找不到错误,而不是example.com/?blah=http://www.test.com
任何mod_rewrite大师都可以提供帮助吗?
发出此请求时,这是一个重写日志:http://www.example.com/blah=http%3A%2F%2Fwww.test.com
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (2) init rewrite engine with requested uri /favicon.ico
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (1) pass through /favicon.ico
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/favicon.ico -> favicon.ico
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (3) [perdir /var/www/html/] applying pattern '(.*)' to uri 'favicon.ico'
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (4) [perdir /var/www/html/] RewriteCond: input='www.example.com' pattern='^example.com' => not-matched
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/favicon.ico -> favicon.ico
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (3) [perdir /var/www/html/] applying pattern '^(.*)$' to uri 'favicon.ico'
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (4) [perdir /var/www/html/] RewriteCond: input='/var/www/html/favicon.ico' pattern='!-d' => matched
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (4) [perdir /var/www/html/] RewriteCond: input='/var/www/html/favicon.ico.php' pattern='-f' => not-matched
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/favicon.ico -> favicon.ico
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (3) [perdir /var/www/html/] applying pattern '.' to uri 'favicon.ico'
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (4) [perdir /var/www/html/] RewriteCond: input='/var/www/html/favicon.ico' pattern='!-f' => matched
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (4) [perdir /var/www/html/] RewriteCond: input='/favicon.ico' pattern='!^$\ [NC]' => matched
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (2) [perdir /var/www/html/] rewrite 'favicon.ico' -> '?/favicon.ico'
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (3) split uri=?/favicon.ico -> uri=, args=/favicon.ico
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (3) [perdir /var/www/html/] add per-dir prefix: -> /var/www/html/
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (2) [perdir /var/www/html/] strip document_root prefix: /var/www/html/ -> /
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55766f8/initial] (1) [perdir /var/www/html/] internal redirect with / [INTERNAL REDIRECT]
[www.example.com/sid#7f0fc51e1860][rid#7f0fc5586f58/initial/redir#1] (2) init rewrite engine with requested uri /
[www.example.com/sid#7f0fc51e1860][rid#7f0fc5586f58/initial/redir#1] (1) pass through /
[www.example.com/sid#7f0fc51e1860][rid#7f0fc5586f58/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/ ->
[www.example.com/sid#7f0fc51e1860][rid#7f0fc5586f58/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '(.*)' to uri ''
[www.example.com/sid#7f0fc51e1860][rid#7f0fc5586f58/initial/redir#1] (4) [perdir /var/www/html/] RewriteCond: input='www.example.com' pattern='^example.com' => not-matched
[www.example.com/sid#7f0fc51e1860][rid#7f0fc5586f58/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/ ->
[www.example.com/sid#7f0fc51e1860][rid#7f0fc5586f58/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '^(.*)$' to uri ''
[www.example.com/sid#7f0fc51e1860][rid#7f0fc5586f58/initial/redir#1] (4) [perdir /var/www/html/] RewriteCond: input='/var/www/html/' pattern='!-d' => not-matched
[www.example.com/sid#7f0fc51e1860][rid#7f0fc5586f58/initial/redir#1] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/ ->
[www.example.com/sid#7f0fc51e1860][rid#7f0fc5586f58/initial/redir#1] (3) [perdir /var/www/html/] applying pattern '.' to uri ''
[www.example.com/sid#7f0fc51e1860][rid#7f0fc5586f58/initial/redir#1] (1) [perdir /var/www/html/] pass through /var/www/html/
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55746e8/subreq] (2) init rewrite engine with requested uri /example.php
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55746e8/subreq] (1) pass through /example.php
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55746e8/subreq] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/example.php -> example.php
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55746e8/subreq] (3) [perdir /var/www/html/] applying pattern '^(.*)$' to uri 'example.php'
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55746e8/subreq] (4) [perdir /var/www/html/] RewriteCond: input='/var/www/html/example.php' pattern='!-d' => matched
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55746e8/subreq] (4) [perdir /var/www/html/] RewriteCond: input='/var/www/html/example.php.php' pattern='-f' => not-matched
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55746e8/subreq] (3) [perdir /var/www/html/] strip per-dir prefix: /var/www/html/example.php -> example.php
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55746e8/subreq] (3) [perdir /var/www/html/] applying pattern '.' to uri 'example.php'
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55746e8/subreq] (4) [perdir /var/www/html/] RewriteCond: input='/var/www/html/example.php' pattern='!-f' => not-matched
[www.example.com/sid#7f0fc51e1860][rid#7f0fc55746e8/subreq] (1) [perdir /var/www/html/] pass through /var/www/html/example.php
答案 0 :(得分:0)
答案 1 :(得分:0)
我遇到了类似的问题:
您
[QSA,L]
应该是
[QSA,L,NE]
看看
http://httpd.apache.org/docs/current/rewrite/flags.html#flag_ne
享受。