Search code examples
asp.net.htaccessmod-rewritehttp-redirecthttp-status-code-301

mod_rewrite multiple ASPX urls


Moved a E-commerce store from a windows aspx server to a new cms on linux. In order to maintain previous sitemap I need to redirect multiple aspx urls to a new aspx url. An example.

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

all need to be redirected to mysite.com/brand-material-style.aspx

I've tried and tried, but cannot get the rewrite to work. Here's what I have now:

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]

Solution

  • Why not a simple redirect?

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