Hello I have a subdomain
Https://apple.example.com
That I want to redirect to
Http://example.com
I tried to write on htaccess of the subdomain this code that I have found on some old question but it's not working
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.yourdomain\.com
RewriteRule ^(.*)$ http://www\.yourdomain\.com/subdomain/$1 [L]
Any help thanks
Try this instead:
RewriteEngine on
RewriteCond %{HTTP_HOST} =apple.example.com
RewriteRule ^ http://example.com%{REQUEST_URI} [R=301,L]
Related
Please help me to fix the issue regarding htaccess redirect from www sub-domain to non-www sub-domain.I tried many codes but not worked.
Best Regards
https://www.sub.domain.com to https://sub.domain.com
Thanks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^sub.example.com$
RewriteRule ^(.*)$ http://www.example.com/sub/$1 [R=301,L]
I want to make a URL change whenever clients access my website with example.com to wwww.example.com I have used .htaccess for this but it works not correct.
Because now a-z0-9.example.com wil also redirect to www.example.com, I want this only works for example.com than redirect to www.example.com
.HTACCESS
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.eample.com/$1 [L,R=301,NC]
Make another .htaccess for a-z0-9.example.com with the code bellow:
RewriteEngine on
RewriteCond %{HTTP_HOST} a-z0-9.example.com [NC]
RewriteRule ^(.*)$ http://www.a-z0-9.example.com/$1 [L,R=301,NC]
I think this will work.
Good Luck!
I moved my site from blog.abc.com to www.abc.com
I want to redirect every request made to blog.abc.com to abc.com
For example:
If blog.abc.com/example.html is requested, it should redirect to www.abc.com/example.html, how can I do it via .htaccess only?
You can put this code in your htaccess (in blog.abc.com root folder)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.(.+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
Using mod_rewrite you could do it like this:
RewriteEngine On
RewriteCondition %{HTTP_HOST} ^blog.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R,L]
or if blog.example.com has its own vhost you could also use mod_alias:
Redirect / http://example.com/
I would like to redirect a subdomain to another subdomain that is not on the same domain.
Example:
subdomain.mydomain.com --> subdomain.myotherdomain.com
I've tried the following code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.domain\.com$ [NC]
RewriteRule ^(.*)$ http://subdomain.myotherdomain.com [R=301,L]
The RewriteCond doesn't seem to work...
Could you guys help me?
Thank you,
Damien
Try it this way in your subdomain root htaccess.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain [NC]
RewriteRule ^(.*)$ http://subdomain.myotherdomain.com [R=301,L]
I use 301 redirect from non-WWW to WWW domain! Works fine, but links are different.
Example:
from - ggkj.com/posts/godzilla/43
to - www.ggkj.com/index.php?view=posts&author=godzilla&aid=43
my .htaccess 301 redirect code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*) http://www.example\.com/$1 [L,R=301]
.htaccess code: http://pastebin.com/t3FA59uq
This is currently what i use on my website with success:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} !^www.walterbax.ca [NC]
RewriteRule ^(.*)$ http://www.walterbax.ca/$1 [R=301,L]
EDIT: after looking into your question a little further I can tell you that your issue is improperly placed in the file. it must be hitting another rule that is rewriting it into URL variables.
I would start with a basic htaccess for the www. rule for testing and add to it from there.
Try this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com$
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]