I'd like to redirect all domains like join.domain.com to signup.domain.com including all URI Params.
I'm not quite sure where to start with this as this should be one rule that blankets all join.* domains on my server.
RewriteEngine On
RewriteCondition %{http_host} ^join$ [NC]
RewriteRule ^(.*)$ http://signup.$1/$ [R=301,L]
Try his rule:
RewriteEngine On
RewriteCondition %{HTTP_HOST} ^join\.(.+)$ [NC]
RewriteRule ^(.*)$ http://signup.%1/$1 [R=301,L]
Related
I need to redirect all sites that as a specific word to one site.
I try to explain myself better.
I have a domain, it's example name is example.com
What I need is when an user digit:
something.example.com
or
anothertext.example.com
or
blablabla.example.com
and many others it will be redirect to example.com
I found this code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)$ https://www.example.com [R=301,L]
But it redirect all my domains in that server.
I discover it because I create a new virtual host, with a new domain but I can't see it on the web because it automatically redirects on example.com
So, I thought that maybe if I specify the word: "example" I can solve the problem.
Sorry for my bad english.
Thanks for help.
Luca.
Check one of rules that you more prefer:
<IfModule mod_rewrite.c>
RewriteEngine on
# something.example.com/any to https://example.com/
RewriteCond %{HTTP_HOST} ^something\. [NC]
RewriteRule (.*) https://example.com/ [R=301,L]
# something.example.com/any to https://example.com/any
RewriteCond %{HTTP_HOST} ^something\. [NC]
RewriteRule (.*) https://example.com/$1 [R=301,L]
# something.example.com/any to https://example.com/, full subdomain with and without www
RewriteCond %{HTTP_HOST} ^(www\.)?something\.example\.com [NC]
RewriteRule (.*) https://example.com/ [R=301,L]
# something.example.com/any to https://example.com/any, full subdomain with and without www
RewriteCond %{HTTP_HOST} ^(www\.)?something\.example\.com [NC]
RewriteRule (.*) https://example.com/$1 [R=301,L]
</IfModule>
I need to make a request to https://subdomain.www.domain.com rewrite the URL to https://subdomain.domain.com
Which part of the below rewrite do I change to achieve this? I'm guessing I have to put the subdomain in front of the www, but what do I put there, also how do I capture all subdomains - what's the general rule for all subdomains?
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
You may use this rule:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.(domain\.com)$ [NC]
RewriteRule ^ https://%1.%2%{REQUEST_URI} [R=301,L,NE]
I have a big issue here.
I have a site example.com, due to the way it was coded, example.com is different from example.com/index. How can i use htaccess to redirect all incoming request from example.com to example.com/index
Here is what i've tried to do but it's not working
The first i did was
RewriteRule ^(.*)$ http://%1/index/$1 [R=301,L]
The second was
RewriteRule ^/index/([^/.]+)/?$ index.php [L]
I'm not so familiar with htaccess though. Any help?
Thanks
NOTE there are so many domain the .htaccess file is working for and i want the rule to affect all e.g example.com should go to example.com/index, example1.com should go to example1.com/index and ... like that
And i already have this rule on top RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
You can use this single rule in the website root .htaccess:
RewriteEngine On
RewriteRule ^/?$ /index [L,R=302]
This will redirect:
example.com => example.com/index
example1.com => example1.com/index
RewriteCond %{HTTP_HOST} =example.com [NC]
RewriteRule ^(.*)$ http://example.com/index.php/$1 [R=301,L]
I have multiple domains directed to folder with .htaccess
my htaccess looks like this:
RewriteEngine On
rewritecond %{http_host} ^domain-2.com
rewriteRule ^(.*) https://domain-1.com/?utm_source=redirects&utm_medium=domain-2.com&utm_campaign=301 [R=301,L]
rewritecond %{http_host} ^domain-3.com
rewriteRule ^(.*) https://domain-1.com/?utm_source=redirects&utm_medium=domain-3.com&utm_campaign=301 [R=301,L]
And I want do this more effective and elegantly - all domains are redirected to domain-1.com
Exist any way how use {HTTP_HOST} or something similar at URL parameters?
Try:
RewriteEngine On
RewriteCond %{HTTP_HOST} !domain-1\.com$ [NC]
RewriteRule ^(.*)$ https://domain-1.com/?utm_source=redirects&utm_medium=%{HTTP_HOST}&utm_campaign=301 [R=301,L]
Hello!
I'm trying to set up my .htaccess file for wildcard subdomains, but I really have no clue how to do that.
I have "domain2" pointing to "domain1" as an alias, which is working perfectly, this is the code I'm using:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www)\.(.*)\.(.*)\.(.*) [NC]
RewriteRule ^(.*)$ http://%2.%3.%4/$1 [R=301,QSA,L]
RewriteCond %{HTTP_HOST} ^(.*\.?)domain2.co\.cc$ [NC]
RewriteRule (.*) http://%1domain1.co.cc/$1 [R=301,L]
I found the www redirect here btw: Optimize htaccess Wildcard Subdomain Code
Now, what I want is all non-existent subdomains to get removed and the ones that exist (like "blog.domain1.co.cc" to stay.
I hope someone can help me with this. Thanks!
RewriteEngine On
#no longer needed
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#don't redirect blog.example.com, forum.example.com and example.com
RewriteCond %{HTTP_HOST} ^((blog|forum)\.)?example\.com$
RewriteRule .* - [L]
#redirect the rest (including www.) to example.com
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Try adding the following to your htaccess file.
#if these lines already exist, skip them
RewriteEngine On
RewriteBase /
#if its not www or discussions subdomain
RewriteCond %{HTTP_HOST} !^(www|discussions)\.domain1\.co\.cc$ [NC]
#redirect to www domain
RewriteRule .* http://www.domain1.co.cc%{REQUEST_URI} [R=301,L]
For the following question
redirects subdomains and subdirectories to the other domain, just like that: forum.old.com/thread/12038213 --> forum.new.com/thread/12038213
Try
RewriteEngine On
RewriteBase /
#if domain is old.com
RewriteCond %{HTTP_HOST} ^(.+)\.old\.com$ [NC]
#redirect to new.com
RewriteRule .* http://%1.new.com%{REQUEST_URI} [L,R=301]