0

將電子商務商店從windows aspx服務器移到linux上的新cms。爲了維護以前的網站地圖,我需要將多個aspx網址重定向到一個新的aspx網址。一個例子。mod_rewrite多個ASPX網址

mysite.com/brand-material-style-large-blue.aspx 
mysite.com/brand-material-style-large-red.aspx 
mysite.com/brand-material-style-med-blue.aspx 

都需要重定向到mysite.com/brand-material-style.aspx

我已經試了又試,但不能得到重寫工作。這裏是我現在有:

RewriteEngine On 
RewriteCond %{REQUEST_URI} brand-material-style(.+)\.aspx [NC] 
RewriteRule ^brand-material-style(.+)$ http://www.mysite.com/brand-material-style.aspx [R=301,L] 
+1

您是否在Apache中安裝並啓用了'mod_rewrite'? –

+0

mod_rewrite確實在Apache中安裝並啓用。 –

回答

1

爲什麼不是一個簡單的重定向?

RedirectMatch (.*)/brand-material-style(.+)\.aspx$ http://www.mysite.com/brand-material-style.aspx 
+0

哇。貢薩洛。這非常出色。我一直在想這個。謝謝。 –

0

我認爲你沒有任何必要的重寫規則...

RedirectMatch (.*)/brand-material-style(.+)\.aspx$ /brand-material-style.aspx [R=301,L] 

你也不需要指定完整的URL,只是文件路徑。並且不要忘記添加屬性(對於301合規性等)