.htaccess tutorial

htaccess Elite


cname to a diffrent folder using the htaccess

Ask your mod_rewrite and Redirection questions here, and get answers!

cname to a diffrent folder using the htaccess

Postby ti89 » 30 Oct 2006 08:00

I know that one can set a cname to a diffrent folder using the htaccess file, would one be able to do that with another domain name?

ie

wholesale-travel.com goes to the main page
while disneywholesaletravel.com goes to wholesale-travel.com/disney

http://brainstormsandraves.com/archives/2005/10/09/htaccess/
Last edited by ti89 on 31 Oct 2006 03:00, edited 1 time in total.
ti89
 
Posts: 44
Joined: 28 Oct 2006 07:37

Postby ti89 » 30 Oct 2006 08:01

Absolutly. You can even use subdomains for both domain names. I did some experimentation with my website and got it to work using code like this:



Code: Select all
RewriteEngine On
RewriteBase /

# BEGIN REDIRECT CODE FOR TWO DOMAINS WITH SUBDOMAINS
# (Note: The following three lines may be
# copied and repeated for each subdomain.)

RewriteCond %{HTTP_HOST} sub.domain1.com
RewriteCond %{REQUEST_URI} !subdir1/
RewriteRule ^(.*)$ subdir1/$1 [L]

RewriteCond %{HTTP_HOST} sub.domain2.com
RewriteCond %{REQUEST_URI} !subdir2/
RewriteRule ^(.*)$ subdir2/$1 [L]


Code: Select all
# The lines for a second domain follow...
# Note: This must be after all other lines for subdomains.
RewriteCond %{HTTP_HOST} domain2.com
RewriteCond %{REQUEST_URI} !domain2/
RewriteRule ^(.*)$ domain2/$1 [L]


# END OF REDIRECTION CODE



What this does is redirects:
sub.domain1.com to subdir1
sub.domain2.com to domain2/subdir2
domain2.com to domain2

If you don't want to use subdomains for the second domain, simply remove those lines from your htaccess file.

Good luck :)
ti89
 
Posts: 44
Joined: 28 Oct 2006 07:37

Re: cname to a diffrent folder using the htaccess

Postby forum » 24 Jun 2009 21:44

hello

i have some problem too. i cant understand your examples well its seen complex can you give examples with 2 different domain aeme and can you explain

here is my problem
simply i want to point
www.mydomain.com/redirectfolder to www.anotherdomain.com.index.php?sdsdg=kjfgj......

if someone enter this url www.mydomain.com/redirectfolder he/she must be see www.anotherdomain.com.index.php?sdsdg=kjfgj...... page bot under my domain www.mydomain.com/redirectfolder

ex- 2
www.mydomain.com/specialfolder/ in the httacces when system catch the specialfolder/ string in the url system must be show www.anotherdomain.com/somepage.html page without changing url
forum
 
Posts: 2
Joined: 24 Jun 2009 21:15


Return to Redirect or Rewrite Questions



cron