【发布时间】:2021-07-19 18:00:36
【问题描述】:
阅读 this 和 bababa,但遗憾的是他们都不能指导我如何调试。
我正在尝试重定向以下网址 https://example.com/hello 至 https://example.com/hello.html
这就是我的做法
第一
vim /etc/apache2/apache2.conf,在<Directory /var/www/>中设置AllowOverride All
现在是
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
第二
sudo service apache2 restart
第三
在public_html 及以下代码中创建.htaccess
<IfModule mod_rewrite.c>
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^.*\.html$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ %{REQUEST_FILENAME}.html
</IfModule>
但仍然返回 404 not found ,如下所示。
配置 apache 有什么建议或我缺少的任何部分吗?谢谢
-----ANSWER------
错过了mod_rewrite 的配置。可以查看这个post
【问题讨论】: