Really struggling with 301 redirects
-
Hello folks, I have searched high and low and need some help sorting out a 301 redirect using an .htaccess file. All sources I have found are very specific and incomprehensible to me, having not done this before. I’m at my wits end trying to decode Apache syntax with no experience.
Basically, I have moved WP site to a new URL and hosting. I’m currently trying to redirect the old post URLs, which have had the same structure retained on the new site.
My issue is the www version of the old URL is not redirecting, but the non-www is. In my old WP site it was installed in a subfolder ‘wordpress’ that didn’t display. I need 3 rules to be followed, where ‘*’ is a wildcard…
1) https://www.olddomain.com/* –> newdomain.net/*
2) oldomain.com/* –> newdomain.net/*
3) non-essential, only for files: olddomain.com/wordpress/* –> newdomain.net/*Here is what is currently in my .htaccess file with any ‘rewrite’ stuff, the 301 redirect is the only one I have added myself:
————————————
RewriteEngine OnRewriteCond %{HTTP_HOST} !^www\.olddomain\.com
RewriteRule (.*) https://newdomain.net/$1 [R=301,L]RewriteCond %{HTTP_HOST} ^olddomain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/wordpress/
RewriteRule ^(.*)$ /wordpress/ [L]# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule># END WordPress
—————————
- The topic ‘Really struggling with 301 redirects’ is closed to new replies.