【问题标题】:Redirect all .html extensions on my website to without the extension [duplicate]将我网站上的所有 .html 扩展名重定向到没有扩展名 [重复]
【发布时间】: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]

但这似乎一点帮助都没有!

如果我没有这个文件,我仍然可以删除扩展名并且页面可以正常工作。

【问题讨论】:

标签: html .htaccess


【解决方案1】:

尝试将您的RewriteRule 更改为:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.html [NC,L]

【讨论】:

  • 我已经尝试过了,但没有任何改变。我只是在我的根文件夹中放入一个名为 .htaccess 的文件,可以吗?
  • 这不是我要找的:stackoverflow.com/a/5730126/2768038我不想更改所有链接
猜你喜欢
  • 1970-01-01
  • 2023-03-14
  • 1970-01-01
  • 2012-03-04
  • 2012-10-24
  • 2012-12-20
  • 1970-01-01
  • 2011-12-28
  • 1970-01-01
相关资源
最近更新 更多