Reputation: 195
I transferred my website from olddomain.de to newdomain.de and wanted to redirect every page of the old website to the new website (e.g. olddomain.de/contact -> newdomain.de/contact). When I enter the main page of the old website in the browser, I am redirected correctly but all other pages are not redirected.
I tried a lot of different redirect options and currently this one is implemented (the first IfModule already existed):
# 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>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.de/$1 [R=301,L]
</IfModule>
# END WordPress
Does anyone know how to correct the .htaccess file, so that all pages of the website are being redirected?
I managed to get all sites redirected by putting some code at the top of the IfModule like this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^olddomain.de$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.de$
RewriteRule (.*)$ http://newdomain.de/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Since this is working fine now, I wanted to change the address in the google search console but it says that the 301 redirection is not working. Does anyone have any suggestions here?
Upvotes: 0
Views: 59
Reputation: 356
since your old site is not serving a WordPress instance anymore try removing the first part of your .htaccess file (you don't need it and may be causing the issue.
So let it just like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.de/$1 [R=301,L]
</IfModule>
Upvotes: 0