Nitesh N Sin
Nitesh N Sin

Reputation: 1

redirection gone wrong htaccess

The url gets redirected to https://2day.news/ instead of https://www.2day.news/. This happens on every browser/mobile, cleared caches. I don't think this has anything to do with a server back-up as it goes blank when I change the redirect to a page that doesn't exist.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^2day.news [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.2day.news/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Upvotes: 0

Views: 69

Answers (2)

Pawan Thakur
Pawan Thakur

Reputation: 591

Add 301, www and https after RewriteBase

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.2day\.news$ [NC]
RewriteRule ^(.*)$ https://www.2day.news/$1 [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Upvotes: 1

On some servers, redirecting from non-www to www in the .htaccess will cause Too many redirections error. So I recommend changing the siteurl in the database.

You can change the URL of the site in the wp_options table, in the option_value column of the following options: siteurl, home.

Or alternatively in the WP admin, under Settings > General (Wordpress URL and Site URL).

You need to add the www. prefix for both options.

Please note:

  • Both records should be the same (or some functions may not work because of cross-domain issues)
  • You need to login again to WP admin after the changes

Upvotes: 0

Related Questions