我正在为 contact.html 文件创建一个重定向地址,例如 http://lorem.com/contact/ ,该文件位于根文件夹中。有没有工具或文件可以做到这一点?
我曾尝试将 contact.html 重命名为 index.html ,然后将其设为 / contact 文件夹。它的工作地址为 http://lorem.com/contact/ ,但我认为这不是一种正确的方法。
(注意:标题可能很奇怪,因为不知道用什么关键字来描述这个。感谢任何编辑方面的帮助。)
答案 0 :(得分:0)
With .htaccess under apache you can do the redirect like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
As for removing of .html from the url, simply link to the page without .html