我有一個使用CMSMadeSimple(基於PHP)的新網站設置,但我遇到了問題301使用新設置重定向舊網站URL。由於URL重寫導致301重定向的問題
我使用CMS的標準.htaccess文件,它將http://www.example.com/test.html等SEO友好URL轉換爲http://www.example.com?page=test,但我也需要在此文件中重定向舊URL(ASP站點)。
我當前的.htaccess如下圖所示,我已經嘗試添加該行
redirect 301 /test.asp http://www.example.com/test.html
,但是當我這樣做的頁面重定向到http://www.example.com/test.html?page=test.asp沒有http://www.example.com/test.html要求
# BEGIN Optional settings
# Turns off directory browsing
# not absolutely essential, but keeps people from snooping around without
# needing empty index.html files everywhere
Options -Indexes
# Deny access to config.php
# This can be useful if php ever breaks or dies
# Use with caution, this may break other functions of CMSms that use a config.php
# file. This may also break other programs you have running under your CMSms
# install that use config.php. You may need to add another .htaccess file to those
# directories to specifically allow config.php.
<Files "config.php">
order allow,deny
deny from all
</Files>
# Sets your 403 error document
# not absolutely essential to have,
# or you may already have error pages defined elsewhere
ErrorDocument 403 /forbidden403.shtml
# No sense advertising what we are running
ServerSignature Off
# END Optional Settings
# BEGIN CMSMS and Rewrite Rules
# Make sure you have Options FollowSymLinks
# and Allow on
RewriteEngine On
# Might be needed in a subdirectory
#RewriteBase/
# URL Filtering helps stop some hack attempts
#IF the URI contains a "http:"
RewriteCond %{QUERY_STRING} http\: [OR]
#OR if the URI contains a "["
RewriteCond %{QUERY_STRING} \[ [OR]
#OR if the URI contains a "]"
RewriteCond %{QUERY_STRING} \] [OR]
#OR if the URI contains a "<script>"
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
#OR script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
#OR any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^.*$ - [F,L]
# END Filtering
# CMSMS Rewriting
# Set assume mod_rewrite to true in config.php and clear CMSMS cache
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?page=$1 [QSA]
# END CMSMS
# END Rewrite rules
任何幫助將不勝感激。
只是想補充一點,我有這個麻煩,直到我把301重定向在我的所有其他重定向規則的開始。這個語法雖然是最後的工作。 – 2013-10-18 21:21:57
您正在改寫爲SEO/SEF格式,然後您需要重寫爲最終的「動態」格式。您必須先執行此操作,或直接將其重寫爲最終格式。 – 2013-12-27 18:13:48