.htaccess redirect

driveflexfuel

New Member
Messages
159
Reaction score
0
Points
0
I have a wildcard redirect set for my domain as *.website.com

I am trying to figure out how I can setup the .htaccess redirect to point correctly

Subdomain test.website.com
Files are in website.com/test

I still want the url at the top to point to test.website.com
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
That's just a subdomain..

Set it up in cpanel.
 

driveflexfuel

New Member
Messages
159
Reaction score
0
Points
0
It is a wildcard redirect as I said. I have an outside company that creates a client id the id then becomes the subdomain the subdomain is only used to signify their own copy of the site. I have been trying to figure out how to set it up properly so that whatever they type it shows up with the same files but still contains their subdomain in the address.

The files are all located in /subdomain
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
If you are talking about an x10 account, I'm pretty sure there is no way to do it.

Where you have a bit more control over the server, you should be able to do it.
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
What you're trying to do requires a combination of a wildcard subdomain virtualhost and a URL rewriting .htaccess. Unfortunately, setting up a wildcard subdomain requires access to the virtualhosts setup in the Apache configuration, which is only available on a VPS and not free. I don't think it is available on x10premium either, but it may be possible through some more advanced cPanel options.
 

driveflexfuel

New Member
Messages
159
Reaction score
0
Points
0
I have a premium hosting package with the wildcard redirect in place. My issue here is that no one knows the proper way to setup the .htaccess file to only direct one domain name and not the rest that are hosted on my package.

If you know how to modify the .htaccess file properly im all ears.
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
Ok, I see now. What are the specifics (file paths, subdomains etc) that need to be redirected and where to?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Are you looking for something like:
Code:
# redirect host "test" to "/test" internally, unless URL already begins with "test"
RewriteCond %{HTTP_HOST} test.website.com
RewriteCond $1 !^test(/|$)
RewriteRule ^/?(.*) /test/$1
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Are you looking for something like:
Code:
# redirect host "test" to "/test" internally, unless URL already begins with "test"
RewriteCond %{HTTP_HOST} test.website.com
RewriteCond $1 !^test(/|$)
RewriteRule ^/?(.*) /test/$1

Except that 'test' can be any string.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
I thought driveflexfuel wrote he only wanted to redirect a single subdomain. For mapping all subdomains to sub-directories, perhaps something like:
Code:
# ensure that subdomain refers to an existing sub-directory
RewriteCond %{HTTP_HOST} ^([^.]+)\.website\.com$
RewriteCond %{DOCUMENT_ROOT}/%1 -d
RewriteRule ^ - [C]

# map subdomain to sub-directory if not already present in URL
RewriteCond %{HTTP_HOST} !^(www\.)?website\.com$
# get the subdomain name
RewriteCond %{HTTP_HOST} ^([^.]+)\.website\.com$
# don't add subdir if already present
RewriteCond %1/$1 !^([^/]+)/\1
RewriteRule ^/?(.*) /%1/$1
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Note that neither has been tested.
 
Top