CNAME subdomain redirect to subdirectory - .htaccess

We have a subdomain setup as a CNAME and would like it redirected to a sub directory, unfortunately I haven't done this before and need some help with it.
So it's setup as:
support.example.com CNAME example.com
We would like it to redirect to:
example.com/support/
I've tried to put this in the .htaccess file in the public_html of example.com but it's not redirecting and I'm not sure where to go next:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^support.example.com
RewriteRule ^(.*)$ http://example.com/support/$1 [L,NC,QSA]
Any help would be appreciated, thank you!

Related

How to add www before subdomain in htaccess

So, we printed some cards but the card accidentally has www.sub.domain.com/example but when to try to go there it says the site cannot be reached but If we try to go to sub.domain.com/example it works.
The main website is made in WordPress but the landing pages (subdomains) are made using Unbounce can this be fixed using .htaccess? if so then which .htaccess file and how can we fix this.
Thank you
You need to redirect your www to non-www. That can be done by adding this to your .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
Don't forget to change yourdomain with your domain.

.htaccess redirect all subfolders to http except main domain

Hello!
Please help me!
I have a main domain "domain.com"
And i have a subfolders
--folder_one
--folder_two
--folder_three
--folder_four
...
How can i, using, htaccess, redirect users from http://example.com to https://example.com and if user going to any subfolder in this domain redirect him to http of this, Example: https://example.com/folder_one to https://example.com/folder_one
I have done this, but i get a permanent redirect.
Please help.
Many thanks!
This redirect main domain to http and subfolders to https. I want exactly the opposite
RewriteCond %{HTTP_HOST} !^example\.com$ [NC,OR]
RewriteCond %{HTTPS} on
RewriteRule ^ http://example.com%{REQUEST_URI} [NE,R=301,L]

Redirect parent domain to subfolder

I know there are a lot of similar questions, still I need your help.
My main site (maindomain.com) is in the root directory of the server public_html.
I have created a subdomain example.maindomain.com and it is in the sub-folder public_html/example
I parked the domain example.net and I need it to point to public_html/example and I need to create the rewrite rules in .htaccess
Still, I maindomain.com to work normally, not redirect from it.
I tried but no success:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.net$
RewriteRule ^(.*)$ /example/$1 [L]

htaccess redirect subdomain to $_GET

Need some help with htaccess
For a sort of image storage site i need this:"
if users come to http:// subdomain.mysite.com/#RANDOMSTRING/ the server has to act like if it is the url: http:// subdomain.mysite.com/index.php?image=#RANDOMSTRING, but the visitor doesnt have to see this.
Also, on www. mysite.com (so not in the subdomain) there is a wordpress with htaccess for seo friendly urls. (Don't know if this has something to do with it, but because i need to upload files for http:// subdomain.mysite.com to ftp:// www.mysite.com/subdomain)
Hope to hear from you, thank you!
In the htaccess file in the subdomain.mysite.com document root add:
RewriteEngine On
RewriteRule index\.php - [L]
RewriteCond %{HTTP_HOST} ^subdomain.mysite.com$ [NC]
RewriteRule ^(.+?)/?$ /index.php?image=$1 [L]
You may not need the RewriteCond at all because it seems your 2 domains (subdomain and www) are in different document roots.

url redirecting through htaccess

i have hosted two sites on same server and i mange them giving folders for each domain. i want to site comes as
example.com/example
example1.com/example1
i want to come
example.com and example.com
i come to know that htaccess url redirecting can do this but i have less idea about it.
if there is some tutorial on php regular expression please let me know.
some help is appreciable.
edited
i solved this problem by putting .htaccess file in root and writing:
RewriteEngine On
#for example.com
RewriteCond %{HTTP_HOST} example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/example/.*$
RewriteRule ^(.*)$ /example/$1 [L]
when i hit example.com it works fine now. it access the folder /example. but i had a problem on a certain domain. i m using codeigniter and i have to redirect its request also so that it does not show
example.com/example/index.php/controller/
i want to show this:
example.com/controller/
hope some experts can help.
The .htaccess url redirecting is setup as a file in your main directory and your code can look something like this:
# These redirects should do the trick :-)
Redirect example.com/example http://www.example.com
Redirect example.com/example1 http://www.example.com

Resources