我有一个Kohana 3.3应用程序,我已经从.htaccess文件中的某些规则中删除了/index.php/
。一切都工作正常,直到我来使用基本身份验证。我无法从$_SERVER
访问Basic Auth,因为该网站是使用php-cgi,which is explained here提供的。
上一个链接中的解决方案有效,但它将/index.php/
添加回URI。我似乎无法在没有服务器投掷500的情况下添加新的重写规则。
以下是我目前的重写规则:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
# Options +SymLinksIfOwnerMatch
Options +FollowSymlinks
RewriteEngine On
# RewriteBase /
</IfModule>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
#RewriteRule .* app/index.php/$0 [PT]
RewriteRule ^(.*)$ index.php/$0 [PT,L]
RewriteRule ^$ index.php/$0 [PT,L]
这就是我需要补充的内容:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^Basic.*
RewriteRule (.*) index.php?Authorization=%{HTTP:Authorization} [QSA,L]
</IfModule>
我该如何使这项工作?是否有一种相对简单的方法来了解mod_rewrite的工作原理?
答案 0 :(得分:1)
在DocumentRoot/.htaccess
:
DirectoryIndex index.php
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /api/
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b /index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$0 [L]
RewriteCond %{HTTP:Authorization} ^Basic.*
RewriteRule ^ index.php?Authorization=%{HTTP:Authorization} [L]