我最近通过虚拟机将所有网站从Windows转移到KUbuntu。现在,我无法访问使用重写URL的网站的一部分...
我已经用apache2 conf中的rewrite
和sudo a2enmod rewrite
激活了AllowOverride
模块,并重新启动了apache,但这仍然行不通...
[开始时,我遇到404错误(没有default.conf
AllowOverride
项)现在我有一个500内部错误。我不知道该如何下一步,我用Google搜索了这个问题,但没有任何帮助。
编辑: 500个内部错误是由于我的.htaccess
:
Header add Access-Control-Allow-Origin "*"
我的default.conf
:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
RewriteEngine on
</Directory>
</VirtualHost>
任何想法?
- 我的
.htaccess
中的错误/var/www/html/vl_web/.htaccess:无效的命令“ Header”,可能是拼写错误或由服务器配置中未包含的模块定义的]]
Header
是mod_headers的一部分,需要启用_。 mod_headers被认为是“扩展名”,换句话说:
具有“扩展”状态的模块通常不会编译并加载到服务器中。要启用该模块及其功能,您可能需要更改服务器构建配置文件并重新编译Apache。 (来源:https://httpd.apache.org/docs/current/mod/module-dict.html#Status)
尽管,通常只需要在服务器配置中“启用”即可。 (需要重新启动网络服务器。)
- php错误(在Windows上不会发生,所以很奇怪):未定义的索引:第35行的
/var/www/html/vl_web/government/panel/files/index/row2.php
中的nom,引用者:http://192.168.1.29/vl_web/government/
PHP版本中的差异和/或不同(默认)的error_reporting级别可以解释此处行为的差异。值得注意的是,“未定义索引”消息在PHP 7中成为E_WARNING-以前是E_NOTICE。
- 'LimitInternalRecursion'错误:由于可能的配置错误,请求超出了10个内部重定向的限制。必要时使用'LimitInternalRecursion'增加限制。使用“ LogLevel调试”获取回溯。参考:http://192.168.1.29/vl_web/
这很可能是由于
.htaccess
文件中的重写引起的。
请向您的问题中添加.htaccess
文件的内容。
这里值得注意的是Windows是区分大小写的文件系统,而Linux不是。同一指令在Linux上可能不匹配。
Aside:
想要禁用<Directory /var/www/html> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny allow from all RewriteEngine on </Directory>
您可能
MultiViews
(您已在上面明确启用它)。如果您对mod_rewrite进行了大量操作(在.htaccess
中),则MultiViews
通常会导致冲突(取决于您在做什么)。您是否真的要启用目录Indexes
?
Order
和Allow
是Apache 2.2指令。您显然在Apache 2.4上,因此应该改用Require
指令。
除非您不在此范围内使用,否则无需启用RewriteEngine
。如果您使用的是.htaccess
,则无论如何这将很可能会覆盖它。
换句话说,这应该写成:
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>