【问题标题】:.htaccess url rewrite does not return entire URL.htaccess url 重写不返回整个 URL
【发布时间】:2012-09-01 06:32:53
【问题描述】:

.htacess 我用过的规则 -

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+)/?$ profile.php?user=$1 [L]
RewriteRule  ^(.*)$ profile.php?user=$1 [QSA,NE]

正确的例子 -

http://mydomain.com/http://fatalweb.com/articles/8/definitions-for-htaccess-regex-character

传递给 $1 的值是 - http://fatalweb.com/articles/8/definitions-for-htaccess-regex-character

http://mydomain.com/https://www.google.com/search?q=_get&ie=utf-8&oe=utf-8&aq=t

传递给 $1 的值是 - https:/www.google.com/search

我如何确保整个 url https://www.google.com/search?q=_get&ie=utf-8&oe=utf-8&aq=t 连同所有查询参数都传递给 $1

【问题讨论】:

    标签: php regex apache


    【解决方案1】:

    在你的问题中,是https:/www.google.com/search吗? https:/ 后面有一个斜线。

    在使用空文件处理程序之前,您需要指定至少一个规则。不知道为什么,但这就是它的工作方式。看看你的用例:

    RewriteEngine On
    RewriteRule ^([^/]*)\.dummy$ ./?dummy=$1&%{QUERY_STRING} [L]
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ ./%{QUERY_STRING}
    

    RewriteRule ^([^/]*)\.dummy$ ./?dummy=$1&%{QUERY_STRING} [L] 行是虚拟的。检查并查看这是否适合您! :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-18
      相关资源
      最近更新 更多