【发布时间】:2014-10-18 06:58:54
【问题描述】:
我正在使用我的 .htaccess 将 Authorization 标头重写为 get 参数。我这样做的原因描述为here。
所以我的问题是,当我在请求 API 时使用查询字符串时,旧的查询字符串会从 URL 中删除。我想要做的是附加一个名为“授权”的查询,而不是像这里所做的那样重写我的 index.php 后面的所有内容。
RewriteEngine on
RewriteBase /api/
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$0 [L, QSA]
RewriteCond %{HTTP:Authorization} ^Basic.*
RewriteRule ^ index.php?Authorization=%{HTTP:Authorization} [L]
有什么想法吗?
【问题讨论】:
-
为什么在第二次重写中不使用
QSA标志? -
当我附加 QSA 时,我得到了 500。我可能需要更改 rewriteRule 吗?我绝对不是 .htaccess 和重写的大师。
标签: regex apache .htaccess mod-rewrite query-string