: 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.
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?
More posts by @Megan663
1 Comments
Sorted by latest first Latest Oldest Best
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.