Forum Moderators: phranque
how can i make a .htaccess redirect so when i add one domain to redirect to that domain but other folder
like 1domain.com to redirect to 1domain.com/domain1/
2domain.com to redirect to 2domain.com/domain2/
i whant if possible for both www and with no www oth to redirect
thank you
Note that you do not use an external redirect, you use an internal rewrite. In this way, the subdirectories are never exposed to the client, and each appears to be a stand-alone domain.
Jim
because the company is asking 7$ for a domain redirect like that
i wanted to redirect because all domains point to one directory and now every domain pints to its directory
where the main domain is other
and here it is
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain2.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain2.com$
RewriteRule ^/?$ [domain2...] [R=301,L]
If you want it indexed as a domain, then you need a rewrite. It is almost the same code, but without the [R=301] part included.
You'll also need to pick up the URL path in a (.*) and then use it in the rewrite using the $1 syntax.
The target URL of the rewrite should not include the "http://domain.com" part. It should only include the file path on the server.
RewriteCond $1 !^aod_
RewriteCond %{HTTP_HOST} ^(www\.)?(domain2\.com) [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?(domain3\.com) [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?(domain4\.com)
RewriteRule (.*) /aod_%2/$1 [L]
And just for good measure, add
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /aod_
RewriteRule ^aod_ - [F]
Jim