Apache 将子域重写为文件,然后删除.htaccess身份验证

Apache 将子域重写为文件,然后删除.htaccess身份验证,apache,.htaccess,mod-rewrite,symfony1,Apache,.htaccess,Mod Rewrite,Symfony1,我正在为Symfony 1.4项目重写一个域 我的.htaccess AuthUserFile /var/www/.htpasswd AuthType Basic AuthName "GH Auth" <Files "*"> require valid-user </Files> <Files "api.php"> Allow from all Satisfy any </Files> <Files "apc.p

我正在为Symfony 1.4项目重写一个域

我的.htaccess

AuthUserFile /var/www/.htpasswd
AuthType Basic
AuthName "GH Auth"

<Files "*">
    require valid-user
</Files>

<Files "api.php">
    Allow from all
    Satisfy any
</Files>

<Files "apc.php">
    require user admin
</Files>

<IfModule mod_rewrite.c>
  RewriteEngine On

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  RewriteBase /

RewriteCond %{HTTP_HOST} ^api\.domain\.org$
RewriteRule ^(.*)$  api.php [QSA,L]

# we skip all files with .something
RewriteCond %{REQUEST_URI} \.(css|js|png|gif|jpg)$
RewriteRule .* - [L]

# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f

# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]

</IfModule>
AuthUserFile/var/www/.htpasswd
AuthType Basic
AuthName“GH Auth”
需要有效用户
通融
满足任何
需要用户管理员
重新启动发动机
#如果遇到问题,请取消对以下行的注释
#无法使用脚本名称
重写基/
重写cond%{HTTP_HOST}^api\.domain\.org$
重写规则^(.*)$api.php[QSA,L]
#我们跳过了所有的文件
重写条件%{REQUEST_URI}\(css | js | png | gif | jpg)$
重写规则。*-[L]
#我们检查.html版本是否在这里(缓存)
重写规则^$index.html[QSA]
重写规则^([^.]+)$$1.html[QSA]
重写cond%{REQUEST_FILENAME}-F
#不,所以我们重定向到前端web控制器
重写规则^(.*)$index.php[QSA,L]
正确访问domain.org/api.php/method允许您在不进行身份验证的情况下继续操作

但是,转到api.domain.org/method似乎看不到该标志,它仍然要求进行身份验证


有什么想法吗?也许是时候创建两个单独的vhost了?

尝试转到
应用程序/api/[您的_模块]
,您应该看到操作文件夹和模板文件夹,然后在模块文件夹(与操作和模板文件夹平行)中添加一个名为
配置的文件夹(如果没有),然后在config文件夹中添加一个名为
security.yml
的文件

在security.yml中添加以下代码

all:
  is_secure: false

请记住,因为您只想删除模块的身份验证过程,所以您编辑的config文件夹中的security.yml文件应该在模块文件夹中,而不是在应用程序文件夹中。因为应用程序文件夹中也有config文件夹。

您是否尝试在重写规则中使用
PT
标志?与
L
配对的“Pass-Through”告诉apache通过映射引擎运行生成的URI;它是关于HTTP基本身份验证的。请再次阅读我的代码示例。。。