Redirect old URLs before rewriting them

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 2
Joined: 17 Apr 2012, 09:45

Redirect old URLs before rewriting them

17 Apr 2012, 09:50

I have the following code in my .htaccess file and I want to know where I should put permenant redirects and also how they should be written?

I want to redirect http://www.domain.com/en/collection.asp to http://www.domain.com/collection.asp
AND http://www.domain.com/en/available-offspring.asp to http://www.domain.com/for-sale.asp

Code: Select all
RewriteEngine ON

#RewriteCond %{HTTPS} (on)?
#RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
#RewriteCond %{REQUEST_URI} (.+)
#RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]

RewriteBase /

#News

RewriteCond %{REQUEST_METHOD} !^POST
RewriteCond %{QUERY_STRING} ^Headline=([^=&]+)&ID=([^=&]+)$
RewriteRule ^news\.asp$ news/%1/%2/? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^news/([^/]+)/([^/]+)/?$ news.asp?Headline=$1&ID=$2 [NC,L]


Many thanks
Simon

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect old URLs before rewriting them

18 Apr 2012, 06:41

Hello Simon,

It doesn't matter where to put these particular, try using:

Code: Select all
# redirect from /en/collection.asp --> /collection.asp
RewriteRule ^en/collection\.asp$ /collection.asp [NC,R=301,L]

#redirect from /en/available-offspring.asp --> /for-sale.asp
RewriteRule ^en/available-offspring\.asp$ /for-sale.asp [NC,R=301,L]


Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 18 guests