1

I currently have a website that is redirecting from -

#-- Redirect http://www.mywebsite.com/en/index.php ---> http://www.mywebsite.com/
#Redirects
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/en/index.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST} [R=301,L]

I need to add another condition for it to redirect from mywebsite.com ---> http://www.mywebsite.com/

Basically i need to add a statement to redirect non www users to force them into wwww.

How can i do this without both conditions and rules messing each other up?

Any help is appreciated

Tim Valishin
  • 51
  • 1
  • 7

1 Answers1

0
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com
RewriteRule ^(.*)$ http://www.mywebsite.com$1 [L]
RewriteCond %{REQUEST_URI} ^/en/index.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST} [R=301,L]

It is possible not to mention mywebsite.com at all, just to check the starting www and use backreference for the domain (did not check the rule).

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.(.*)$
RewriteRule ^(.*)$ http://www.%1$1 [L]
RewriteCond %{REQUEST_URI} ^/en/index.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST} [R=301,L]
Cheery
  • 16,063
  • 42
  • 57