【发布时间】:2017-02-19 21:26:51
【问题描述】:
我正在尝试创建一个重写规则,将带参数的 URL 更改为只是一个正斜杠后跟一个参数。
重写规则:
RewriteRule ^(.*)$ send.php?url=$1&name=&submit=submit [NC,L]
上面的规则应该适用于 URL:
example.com/google.com
但是,尽管 URL example.com/google.com 保留在浏览器栏中并且我没有收到 404 或 500 服务器错误,但不是将 google.com 作为参数添加,而是将 send.php 作为 URL 参数添加。
网址应转到:
send.php?url=google.com&name=&submit=submit
但它目前转到:
send.php?url=send.php&name=&submit=submit
有趣的是,如果我稍微更改RewriteRule,一切正常。
工作RewriteRule
RewriteRule ^send/(.*)$ /send.php?url=$1&name=&submit=submit [NC,L]
这是RewriteRule 的工作版本和非工作版本的日志副本。
登录(工作)RewriteRule ^send/(.*)$ /send.php?url=$1&name=&submit=submit [NC,L]
[2016 年 10 月 11 日星期二 11:03:09.500902] [rewrite:trace3] [pid 6376:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:14876] 127.0.0.1 - - [example.com /sid#611988][rid#2f16c40/initial] [perdir C:/xampp/htdocs/test/] 添加路径信息后缀:C:/xampp/htdocs/test/send -> C:/xampp/htdocs/test/发送/google.com
[2016 年 10 月 11 日星期二 11:03:09.500902] [rewrite:trace3] [pid 6376:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:14876] 127.0.0.1 - - [example.com /sid#611988][rid#2f16c40/initial] [perdir C:/xampp/htdocs/test/] 去除每个目录前缀:C:/xampp/htdocs/test/send/google.com -> send/google。 com
[2016 年 10 月 11 日星期二 11:03:09.500902] [rewrite:trace3] [pid 6376:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:14876] 127.0.0.1 - - [example.com /sid#611988][rid#2f16c40/initial] [perdir C:/xampp/htdocs/test/] 将模式 '^send/(.*)$' 应用于 uri 'send/google.com'
[2016 年 10 月 11 日星期二 11:03:09.500902] [rewrite:trace2] [pid 6376:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:14876] 127.0.0.1 - - [example.com /sid#611988][rid#2f16c40/initial] [perdir C:/xampp/htdocs/test/] 重写 'send/google.com' -> '/send.php?url=google.com&name=&submit=submit'
[2016 年 10 月 11 日星期二 11:03:09.500902] [rewrite:trace3] [pid 6376:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:14876] 127.0.0.1 - - [example.com /sid#611988][rid#2f16c40/initial] 拆分 uri=/send.php?url=google.com&name=&submit=submit -> uri=/send.php, args=url=google.com&name=&submit=submit
登录(不工作)RewriteRule ^(.*)$ send.php?url=$1&name=&submit=submit [NC,L]
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3314c38/initial] [perdir C:/xampp/htdocs/test/] 去除每个目录前缀:C:/xampp/htdocs/test/google.com -> google.com
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3314c38/initial] [perdir C:/xampp/htdocs/test/] 将模式 '^(.*)$' 应用于 uri 'google.com'
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace2] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3314c38/initial] [perdir C:/xampp/htdocs/test/] 重写 'google.com' -> 'send.php?url=google.com&name=&submit=submit'
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3314c38/initial] 拆分 uri=send.php?url=google.com&name=&submit=submit -> uri=send.php, args=url=google.com&name=&submit=submit
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3314c38/initial] [perdir C:/xampp/htdocs/test/] 添加每个目录前缀:send.php -> C:/xampp/htdocs/test/send.php
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace2] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3314c38/initial] [perdir C:/xampp/htdocs/test/] 去除 document_root 前缀:C:/xampp/htdocs/test/send.php -> /send.php
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace1] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3314c38/initial] [perdir C:/xampp/htdocs/test/] 内部重定向与 /send.php [内部重定向]
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#331af78/initial/redir#1] [perdir C:/xampp/htdocs/test/] 去除每个目录前缀:C:/xampp/htdocs/test/send.php -> 发送。 php
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#331af78/initial/redir#1] [perdir C:/xampp/htdocs/test/] 将模式 '^(.*)$' 应用于 uri 'send.php'
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace2] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#331af78/initial/redir#1] [perdir C:/xampp/htdocs/test/] 重写 'send.php' -> 'send.php?url=send.php&name=&submit=submit '
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#331af78/initial/redir#1] 拆分 uri=send.php?url=send.php&name=&submit=submit -> uri=send.php, args=url=send.php&name=&submit=提交
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#331af78/initial/redir#1] [perdir C:/xampp/htdocs/test/] 添加每个目录前缀:send.php -> C:/xampp/htdocs/test/send。 php
[2016 年 10 月 11 日星期二 11:21:58.485476] [rewrite:trace1] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#331af78/initial/redir#1] [perdir C:/xampp/htdocs/test/] 初始 URL 等于重写 URL: C:/xampp/htdocs/test/send.php [忽略重写]
[2016 年 10 月 11 日星期二 11:22:03.862783] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3316c40/initial] [perdir C:/xampp/htdocs/test/] 添加路径信息后缀:C:/xampp/htdocs/test/css -> C:/xampp/htdocs/test/ css/style.css,引用者:http://example.com/google.com
[2016 年 10 月 11 日星期二 11:22:03.862783] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3316c40/initial] [perdir C:/xampp/htdocs/test/] 去除每个目录前缀:C:/xampp/htdocs/test/css/style.css -> css/style。 css,引用者:http://example.com/google.com
[2016 年 10 月 11 日星期二 11:22:03.862783] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3316c40/initial] [perdir C:/xampp/htdocs/test/] 将模式 '^(.*)$' 应用于 uri 'css/style.css',引用者:http://example.com/google.com
[2016 年 10 月 11 日星期二 11:22:03.862783] [rewrite:trace2] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3316c40/initial] [perdir C:/xampp/htdocs/test/] 重写 'css/style.css' -> 'send.php?url=css/style.css&name=&submit=submit ',引用者:http://example.com/google.com
[2016 年 10 月 11 日星期二 11:22:03.862783] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3316c40/initial] 拆分 uri=send.php?url=css/style.css&name=&submit=submit -> uri=send.php, args=url=css/style.css&name=&submit=提交,推荐人:http://example.com/google.com
[2016 年 10 月 11 日星期二 11:22:03.862783] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3316c40/initial] [perdir C:/xampp/htdocs/test/] 添加每个目录前缀:send.php -> C:/xampp/htdocs/test/send.php,引用者: http://example.com/google.com
[2016 年 10 月 11 日星期二 11:22:03.862783] [rewrite:trace2] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3316c40/initial] [perdir C:/xampp/htdocs/test/] 去除 document_root 前缀:C:/xampp/htdocs/test/send.php -> /send.php,引用者:@ 987654327@
[2016 年 10 月 11 日星期二 11:22:03.862783] [rewrite:trace1] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3316c40/initial] [perdir C:/xampp/htdocs/test/] 使用 /send.php 进行内部重定向 [INTERNAL REDIRECT],引用者:http://example.com/google.com
[2016 年 10 月 11 日星期二 11:22:03.863783] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3319138/initial/redir#1] [perdir C:/xampp/htdocs/test/] 去除每个目录前缀:C:/xampp/htdocs/test/send.php -> 发送。 php,引用者:http://example.com/google.com
[2016 年 10 月 11 日星期二 11:22:03.863783] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3319138/initial/redir#1] [perdir C:/xampp/htdocs/test/] 将模式 '^(.*)$' 应用于 uri 'send.php',引用者:@987654330 @
[2016 年 10 月 11 日星期二 11:22:03.863783] [rewrite:trace2] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3319138/initial/redir#1] [perdir C:/xampp/htdocs/test/] 重写 'send.php' -> 'send.php?url=send.php&name=&submit=submit ',引用者:http://example.com/google.com
[2016 年 10 月 11 日星期二 11:22:03.863783] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3319138/initial/redir#1] 拆分 uri=send.php?url=send.php&name=&submit=submit -> uri=send.php, args=url=send.php&name=&submit=提交,推荐人:http://example.com/google.com
[2016 年 10 月 11 日星期二 11:22:03.863783] [rewrite:trace3] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3319138/initial/redir#1] [perdir C:/xampp/htdocs/test/] 添加 per-dir 前缀:send.php -> C:/xampp/htdocs/test/send。 php,引用者:http://example.com/google.com
[2016 年 10 月 11 日星期二 11:22:03.863783] [rewrite:trace1] [pid 5176:tid 1632] mod_rewrite.c(476): [client 127.0.0.1:15724] 127.0.0.1 - - [example.com /sid#3e1988][rid#3319138/initial/redir#1] [perdir C:/xampp/htdocs/test/] 初始 URL 等于重写 URL: C:/xampp/htdocs/test/send.php [忽略重写] ,推荐人:http://example.com/google.com
查看日志,它的开头是正确的:url=google.com,然后进一步更改为url=send.php
总而言之,我怎样才能打开这个网址:example.com/send.php?url=google.com&name=&submit=submit
进入这个网址:example.com/google.com
【问题讨论】:
标签: php apache .htaccess mod-rewrite url-rewriting