Apache 如何将.htaccess放入虚拟主机?
我想知道是否可以将.htaccess指令直接放在我的虚拟主机中 我的.htaccess:Apache 如何将.htaccess放入虚拟主机?,apache,Apache,我想知道是否可以将.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] 我尝试使用virtual
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,故意删除了此主题的一些说明:
<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>
它的工作是:
<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>
因此,请查看服务器的错误日志,了解请求失败的原因/原因。加载页面时唯一的日志消息是:error.log of apache[Sat Feb 22:49:48 2014][debug]mod_deflate.c615:[client 192.168.1.66]Zlib:Compressed 302 to 222:URL/index/index/
<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>