我使用我的.htaccess将Authorization标头重写为get参数。为什么我这样做是here。
所以我的问题是当我在请求API时使用查询字符串时,会从URL中删除旧的查询字符串。我想要做的是添加一个名为" Authorization"的查询。而不只是重写我的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]
有什么想法吗?
答案 0 :(得分:2)
这样做:
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.*
RewriteCond %{QUERY_STRING} !Authorization=[^&]*
RewriteRule ^ index.php?Authorization=%{HTTP:Authorization} [L,QSA]