Forum Moderators: phranque

Message Too Old, No Replies

How to redirect domain to a subfolder

without affecting a subdomain

         

studee

5:30 pm on Apr 7, 2008 (gmt 0)

10+ Year Member



I want to direct example.com to /public_html/test and i want the subdomain to be directed to /public_html/subfolder .

so that i can access sub domain as subfolder.example.com

i some how [ newbie ] got the domain diverted with this code .

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} example.com
RewriteCond %{REQUEST_URI} !test/
RewriteRule ^(.*)$ test/$1 [L]

now the subdomain cant be accessed with this subfolder.example.com

i need help on how to divert subdomain rather let them follow normal procedure .

also is it a good thing ?, to do Performance wise !, really looking for help !

Secondly i want to access

example.com/test
through
example.com/TEST ( case senstive)

its not happening now !

Thanks in Advance!

jdMorgan

9:48 pm on Apr 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add a start anchor and escape literal periods in your regular expressions pattern:

RewriteCond %{HTTP_HOST} ^example\.com

Without the start anchor, the pattern will match any hostname that contains "example.com". Adding the start anchor means that the rule will require the hostname to start with "example.com".

See the regular expressions tutorial cited in our forum charter for more information on regular expresions patterns.

Jim

studee

6:03 am on Apr 8, 2008 (gmt 0)

10+ Year Member



Hey Jim!,

Thanks alot It Worked !,

i sure will read the regex tutorial

many thanks Jim!

Dee

studee

7:50 pm on Apr 10, 2008 (gmt 0)

10+ Year Member



Okay now i just realized i cant access my website with

www.example.com but i can access it through example.com

i added the this in my .htaccess

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com
RewriteCond %{REQUEST_URI} !test/
RewriteRule ^(.*)$ test/$1 [L]

what to do now !

jdMorgan

8:39 pm on Apr 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Allow for the optional "www.":

RewriteEngine on
Options +FollowSymlinks
#
RewriteCond %{HTTP_HOST} [b]^(www\.)?e[/b]xample\.com
RewriteCond %{REQUEST_URI} !/test/
RewriteRule (.*) /test/$1 [L]

Jim

[edited by: jdMorgan at 8:40 pm (utc) on April 10, 2008]

studee

9:52 pm on Apr 10, 2008 (gmt 0)

10+ Year Member



Hey Jim !

Thanks Alot Man!

you are the GURU !

;)

Dee