我安装了 Ubuntu 12.10 并安装了 apache2,但我的 .htaccess 文件无法正常工作。我将其设置为在链接中不能包含 .php 文件扩展名,因此看起来像 www.website.com/login 而不是 /login.php,但它说找不到 URL“/login”在服务器上。我读过了这一页 http://www.cyberciti.biz/faq/apache-htaccess/它说了一些关于“AllowOverride All”的内容,但我不知道它在哪里,或者如果我需要添加它,我会在哪里添加它。
EDIT:我已经发现这个链接 https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles并找到了它所说的内容,但它说我在访问的任何页面上都有内部服务器错误。我已更改为
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
但它说内部服务器错误
EDIT #2:在错误日志中,它说
/var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
EDIT #3:在这里找到了答案:.htaccess:无效命令“RewriteEngine”,可能拼写错误或由未包含在服务器配置中的模块定义 https://stackoverflow.com/questions/10144634/htaccess-invalid-command-rewriteengine-perhaps-misspelled-or-defined-by-a-m
- 确保您已在 .htaccess 中启用 mod_rewrite。
还要确保您的 .htaccess 顶部有这些行:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
即转动MultiViews
选项关闭。
另请参阅本次问答 https://stackoverflow.com/questions/16755169/mod-rewrite-is-enabled-but-not-working/16755191#16755191对于类似的问题和我的答案。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)