我有一个有论坛的网站,我正在尝试清理重复的内容问题。
我要做的是301将mywebsite.com/recent-topics/category-title/post-title.html的任何网址重定向到mywebsite.com/forum/category-title/post-title.html。< / p>
这是一个Joomla网站,htaccess文件已经在使用中。我已将此字符串添加到htaccess文件的末尾,但它无效:
RewriteRule ^/recent-topics/(.*) /forum [R=301,L]
完整的htaccess文件:
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]
##
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
##
#RewriteBase /
## Begin - Joomla! core SEF Section.
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/component/) [OR]
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
## End - Joomla! core SEF Section.
RewriteRule ^/recent-topics/(.*) /forum [R=301,L]
任何人都可以提出任何关于我做错的建议吗?
答案 0 :(得分:0)
您需要在RewriteEngine On
下添加规则。重定向需要在之前发生任何类型的路由发生。