I want to make subdomain redirect with "www", but this did not work:
RewriteCond %{HTTP_HOST} !^www\.(blog\.)?example\.com$ [NC]
RewriteRule .? ht-tp://www.%1example.com%{REQUEST_URI} [R=301,L]
Try this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.([^.]*)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.%1example.com/$1 [R=301,L]
Hope that helped!
Related
I would like redirect all my URL to https. But it doesn't work. My .htaccess below. Could you help me please ? Something wrong ? Many thanks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^192.168.1.201
RewriteCond %{HTTP_HOST} !^www.vilabea\.com
RewriteRule ^(.*)$ https://www.vilabea.com/$1 [R=301,L]
RewriteRule ^fr/evenementiel$ https://www.vilabea.com/fr/les-seminaires [R=301,L]
RewriteRule ^fr/les-services$ https://www.vilabea.com/fr/le-restaurant [R=301,L]
RewriteRule ^fr/le-spa$ https://www.vilabea.com/fr/detente-et-bien-etre [R=301,L]
RewriteRule ^es/el-spa$ https://www.vilabea.com/es/descanso-y-bienestar [R=301,L]
RewriteRule ^fr/index_new\.php$ https://www.vilabea.com [R=301,L]
I want to make a rule in my .htaccess file, to redirect my www.example.com and
www.example.com/index.html to example.com
Thanks
You can combine both requirement in a single rule like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\. [NC,OR]
RewriteCond %{THE_REQUEST} /index\.html[?\s] [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^(.*?)(?:index\.html)?$ http://%1/$1 [L,R=301,NE,NC]
Create a .htaccess file. And add this:
#Force non-www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.YOURDOMAIN\.com [NC]
RewriteRule ^(.*)$ http://YOURDOMAIN.com/$1 [L,R=301]
thiis should work seamlessly
RewriteCond %{HTTP_HOST} ^www\.sitename\.com [NC]
RewriteRule ^(.*)$ https://sitename.com/$1 [L,R=301,NC]
I want to set up the redirect, which would bring any user from
http://vps.domain.com/~access/ (and subfolders, such as /~access/user etc.)
to
http://www.example.com
What's the Rewrite rule I have to use?
Will that one work?
RewriteCond %{HTTP_HOST} ^vps.domain.com/~access/$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Thank you!
You can place this rule in ~access/.htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^vps\.domain\.com$ [NC]
RewriteRule ^ http://www.example.com/ [L,R=301]
RewriteCond %{HTTP_HOST} ^vps\.domain\.com [NC]
RewriteCond %{REQUEST_URI} ^/~access/
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
My domain "example.com" is redirected to the "www.example.com".
and the for each it's subdomain "www.subdomain.example.com" is redirected to the "subdomain.example.com" and linked to a root subfolder "example.com/admin". So far so good.
The issue here is when I access to "/admin" for the domain itself i wanted to redirect to "www.example.com/admin" but subdomain to "subdomain.example.com/admin" .
this is my .htaccess file in /admin:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.([^\.]*)\.example\.com$ [NC]
RewriteRule (.*) http://%1.example.com$1 [R=301,L]
Any way I can do this? Much appreciated.
You can do like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.com$ [NC]
RewriteRule ^((?!admin).*)$ http://%1.example.com/$1 [R=301,L]
I am stuck on the follow htaccess situation.
I want to redirect pages to subdomains.
Url example right now;
http://domain.tld/user/foo
I need to redirect this to;
http://foo.domain.tld
The subdomain is genereated by wildcard.
I tried the follow without succes;
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.tld [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.tld?$
RewriteRule (.*) s/index.php?user=%1 [NC,QSA]
RewriteRule ^user/(.*) (.*) [R=301,L]
Regards,
Nick
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.tld [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.tld?$
RewriteRule (.*) s/index.php?user=%1 [NC,QSA]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.tld [NC]
RewriteRule ^user/([a-zA-Z0-9-.]+) http://$1.domain.tld/ [R=301,L]