什么mod_rewrite规则将301重定向/example.html到/example?

发布于 2024-08-24 18:00:43 字数 327 浏览 4 评论 0原文

我想将网址翻译或 301 重定向,例如:

www.domain.com/example.html 到 www.domain.com/example

以下是当前的重写规则:

   RewriteEngine On
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php/$1 [QSA,L]
   RewriteCond %{SERVER_PORT} 80 

I would like to translate or 301-redirect urls such as:

www.domain.com/example.html to www.domain.com/example

Here are the current rewrite rules:

   RewriteEngine On
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php/$1 [QSA,L]
   RewriteCond %{SERVER_PORT} 80 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟花易冷人易散 2024-08-31 18:00:43

请尝试以下操作:

RewriteRule ^(.+)\.html$ $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L]

Please try the following:

RewriteRule ^(.+)\.html$ $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L]
神经大条 2024-08-31 18:00:43

尝试 RewriteRule (.+)\.html$ $1 [R=301]

Try RewriteRule (.+)\.html$ $1 [R=301]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文