我的问题是我的 .htaccess
我的本地服务器上的文件没有被读取。 VirtualHost
中的设置文件似乎总是优先。
我尝试了以下方法:
mod_rewrite
AllowOverride
至All
但这会导致 HTTP Error 500 Internal server error
.我已经尝试了各种选项,但它总是会导致 500 错误。 我在 Ubuntu 上使用 VirtualHost 文件,如下所示:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /web/website
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /web/website>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
在我的
.htaccess
/web/website
下的文件我有以下规则(没有被阅读):RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{HTTP_USER_AGENT} ^facebookexternalhit
RewriteRule ^(.*)$ ogtags.php?$1 [L,QSA]
ErrorDocument 404 /404
ErrorDocument 401 /401
我尝试过的一件事是将这些规则直接附加到 VirtualHost 文件中,但我想要我的
.htaccess
文件工作!有这么大的要求吗? :(编辑:所以我查看了我的 apache
error.log
它说Invalid command 'Action', perhaps misspelled or defined by a module not included in the server configuration
引用我的.htaccess
文件。似乎没有我可以启用的名为 Action 的模块。有任何想法吗?编辑 2:我注意到我的
httpd.conf
文件为空白。既然我正在使用 VirtualHost
,这应该是什么问题吗?文件?
最佳答案
看了我的 apache error.log
我意识到我只需要启用 Apache actions
模块:
sudo a2enmod actions
不再出现 500 个内部服务器错误!
希望这可以帮助某人:)
关于.htaccess - 如何使用 Apache VirtualHost 获取 .htaccess 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14419757/