【发布时间】:2015-11-04 02:51:30
【问题描述】:
目前我的 Apache RewriteRule 仅将原始 URL 的路径作为查询参数传递给重写后的 URL。
如何将整个 URL(包括方案和权限等)作为参数发送到重写的 URL?
我知道%{REQUEST_URI} 只传递路径,我看不到任何传递整个 URL 的 Apache 环境变量。
我是 Apache 配置的初学者,请原谅我的无知,
谢谢!
这是我当前的配置:
#
# Enable Rewrite
#
RewriteEngine On
#
# Condition for rewriting the URL. Check the URL's path is a valid REST URI path
#
RewriteCond %{REQUEST_URI} ^(?:[^?#]*)(?:/v[0-9]+(?:\.[0-9]+)*)(?:/[a-z]+)(?:/[a-z]+)(?:/?[^/?#]*)(?:[^?#]*)$
#
# Rewrite the URL, sending the REST path as a parameter to the specified version.
#
RewriteRule ^(?:[^?#]*)(?:/(v[0-9]+(?:\.[0-9]+)*))((?:/[a-z]+)(?:/[a-z]+)(?:/?[^/?#]*)(?:[^?#]*))$ https://localhost/rest/$1/index.php?request_uri_path=https://localhost/rest/$1/$2 [QSA,NC,L,R=307]
目前我已将 url 硬编码到查询参数中,因此 URL
https://localhost/rest/v1/users/show/12345
变成:
https://localhost/rest/v1/index.php?request_uri_path=https://localhost/rest/v1/users/show/12345
【问题讨论】:
-
apache是哪个版本的?
标签: apache .htaccess mod-rewrite