Mobile app version of vmapp.org
Login or Join
Megan663

: Full domain .htaccess 301 keeping same paths, but also redirect some URLs to different paths I believe the following code will redirect my old domain to my new domain keeping the same URL paths.

@Megan663

Posted in: #301Redirect #Htaccess #Redirects #Seo

I believe the following code will redirect my old domain to my new domain keeping the same URL paths.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.newdomain.co.uk
RewriteRule (.*) www.newdomain.co.uk/ [R=301,L]


However, I also have some URLS from my old site that don't exist on my new site, so they would return a 404 with the rule above.

How do I redirect these to an alternative URL path?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Megan663

1 Comments

Sorted by latest first Latest Oldest Best

 

@Holmes151

You simply need to redirect these specific URLs before your catch-all redirect above. For example:

RewriteRule ^old-url-does-not-exist$ /new-url-that-does-exist [R=301,L]


Just to note... in .htaccess there is no slash prefix on the source URL pattern, ie. the regex ^old-url-does-not-exist$ matches the URL /old-url-does-not-exist. Whereas there is a slash prefix on the destination URL. That's just RewriteRule syntax.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme