Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 如何将.htaccess放入虚拟主机?_Apache - Fatal编程技术网

Apache 如何将.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

我想知道是否可以将.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,故意删除了此主题的一些说明:

<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>