我想知道是否可以将.htaccess指令直接放在我的虚拟主机中。
我的.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
我尝试使用我的虚拟主机(本主题故意删除了一些说明):
<VirtualHost *:80>
ServerName domain.dev
ServerAlias www.domain.dev
<Directory /www/htdocs/domain/html/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
</VirtualHost>
但我的浏览器回复:
Bad Request
Your browser sent a request that this server could not understand.
答案 0 :(得分:0)
它适用于:
<Directory /www/htdocs/domain/html/>
Options -Indexes FollowSymLinks
AllowOverride All
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</Directory>