【发布时间】:2020-11-15 12:24:00
【问题描述】:
.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
通过此设置,页面/foo/bar 可以在漂亮的 URL example.com/foo/bar 下访问,而丑陋的 URL example.com/index.php/foo/bar 仍然有效。我需要实现的是从example.com/index.php/foo/bar 到example.com/foo/bar 的永久重定向。
RewriteRule .* index.php [R=301,L] 不起作用。
RewriteRule (.*) index.php/$1 [R=301,L] 正好相反,它从example.com/foo/bar 重定向到example.com/index.php/foo/bar。请帮帮我!
【问题讨论】:
-
根据 this meta post 和 this meta post,这个问题对于 SO 来说根本不是题外话,所以近距离投票不符合全民公投。
-
我也非常不同意关闭页面的奇怪理由。
-
不,这个问题属于这里,它是关于重写规则,即
mod_rewrite,并且不是 Joomla 特定的。这些重写规则可以在没有 Joomla 的任何本土网站中使用 -
比在平台之间移动问题更好,在Joomla论坛上添加一段与重写规则相关的Joomla问题的有用链接会更好。正如我提议的那样,如果您没有任何异议,我自己会这样做(因为我是那里的新用户)
-
@mickmackusa 让我的问题迁移到 JSE?不,谢谢!
标签: apache .htaccess redirect mod-rewrite url-rewriting