I want to remove www. from start of my URL it tried this :
I have found this work for mydomain.com
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.mydomain\.com)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
If i use mydomain.net.in it doesn't work how to get it done?
RewriteCond %{HTTP_HOST} ^mydomain\.net\.in$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.mydomain\.net\.in)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
I am not sure why you first appending www and then removing try with below, it will work for both.
RewriteCond %{HTTP_HOST} ^www\.(.+)
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
Clear cache beforehand.
Related
I got www ssl certificate. I've to redirect my site https://www.domain-name.com/folder/home.php whenever user typing like http://domain-name.com or https://domain-name.com or domain-name.com
I tried many ways. It's working when I type domain-name.com but it shows privacy error and not redirect while using https://domain-name.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
Please change
RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
To
RewriteRule ^(.*)$ https://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
Try this one:
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
My title says it all. I tried the following, but it only works for the non-https version.
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^ https://www.example.com/members/ [R=301,L]
Try below rule,
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^ https://www.example.com/members/ [R=301,L]
I am currently using this in my htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
But it has the unfortunate effect of redirecting every call to the mobile site (m.example.com) to the main page. How do I make an exception to m.example.com? I don't know how to setup RewriteRule correctly.
You can use:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^m\. [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
And make sure to clear your browser cache.
I would like to convert URLs like subdomain.domain.fr to domain.fr/index.php/subdomain
I tried with that htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain.fr$ [NC]
RewriteRule ^(.*)$ /index.php/%1 [L,QSA]
</IfModule>
With this, my site responds with domain.fr but I get a Internal Server Error with subdomain.domain.fr
Any idea on what I'm doing wrong ?
You're probably getting looping error. You can use this code to avoid it:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^([^.]+).domain\.fr$ [NC]
RewriteRule ^ /index.php/%1 [L]
I want to redirect http://sub.domain.com to http://www.sub.domain.com but also have http://domain.com redirect to http://www.domain.com.
This is what I have for the domain part
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule .? http://www.domain.com%{REQUEST_URI} [R=301,L]
How hard is this to do?
Here is the solution:
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]