【发布时间】:2014-03-15 12:44:22
【问题描述】:
所以我的所有页面上都有指向 shop.html 和 index.html 和 music.html 的超链接。有没有办法(我不必通过每个文件取出.html)来重定向所有这些超链接。
我看过 .htaccess:
Options +ExecCGI +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ /$1.html [L]
但这似乎一点帮助都没有!
如果我没有这个文件,我仍然可以删除扩展名并且页面可以正常工作。
【问题讨论】:
-
您的 .htaccess 仅处理将非 html URL 映射到 html 文件的规则。请参阅链接问题了解如何实现自动重定向。