Вопрос

I have added a 301 redirect to the .htaccess of my Wordpress site but it's broken my site. It shows the following error message:

see link

.htaccess file

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^insurancetailors\.com$ [NC]
RewriteRule ^(.*)$ http://insurancetailors.co.uk[R=301,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
Это было полезно?

Решение

You need a space after the URL:

# here -----------------------------------------v
RewriteRule ^(.*)$ http://insurancetailors.co.uk [R=301,L]

Without the space, apache assumes you want to 302 redirect to the URL: http://insurancetailors.co.uk[R=301,L], which is not what you want, and is infact, throwing a 500 server error. Without the R=301 flag, apache assumes a 302 redirect.


EDIT:

Just to summarize comments:

i want to redirect insurancetailor.com to insurancetailor.co.uk

The rule needs to look like:

RewriteCond %{HTTP_HOST} ^insurancetailors\.com$ [NC]
RewriteRule ^(.*)$ http://insurancetailors.co.uk/$1 [R=301,L]

Другие советы

Try this code:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^insurancetailors\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://insurancetailors.co.uk/$1 [R=301,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top