我应该在Joomla中添加自定义重定向的位置?

时间:2015-10-02 07:53:46

标签: apache .htaccess mod-rewrite joomla url-redirection

我在哪里添加重定向?

基于此页: http://dvlancer.com/67-redirect-pages-with-html-suffix.html

当关闭转动html后缀时,我应该使用它:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ /$1 [R=301,L]

只需将.htaccess(在public_html文件夹中)放在上面就不起作用了:

这应该放在htaccess.txt中吗?它似乎是应该包含自定义内容的部分?

## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
## End - Custom redirects

1 个答案:

答案 0 :(得分:1)

mod_rewrite不是可以在位置关闭的东西。您可以从apache的服务器设置启用/加载重写模块。它通常存储在/etc/apache2/conf.d/中,文件名为httpd.confapache2.conf

在文件中搜索以下文字:

LoadModule rewrite_module modules/mod_rewrite.so

如果是评论(以#开头);取消注释,重新启动服务器。

重写规则需要放在名为 .htaccess 的文件中。文件htaccess.txt可供新开发人员使用,但不会被服务器处理。此外,在评估任何其他重写功能之前,您需要使用RewriteEngine On语句。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ /$1 [R=301,L]