Redirecting a domain into an another directory of same level
Consider there is a domain called mydomain.com, which curretly pointed to a directory named 'folder1' in the home directory(public_html). Now, I just want to redirect this domain to an another directory, which is in the same home folder(public_html named 'folder2'
In this case we could use the following htaccess code, just remember that you have included the 'RewriteEngine On' statement at the beginning of the htaccess file
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteCond %{REQUEST_URI} !^/folder2/
RewriteRule (.*) /folder2/$1
Now the when type mydomain.com/folder2 it will redirect the folder named 'folder2' in which the directory level the folder 'folder1' is. Not to the subfolder of folder1.
Another case of usage of htaccess redirect.
For setting an HTML splash page for your domain.
if you want to redirect all the traffic to the domain mydomain.com/ to a new folder named /anothersub, but you want to keep the other existing subfolders of mydomain.com/ working as they act
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) /anothersub/index.html
In this case the traffic to mydomain.com will go to mydomain.com/anothersub/index.html instead of mydomain.com/index.html.
but the traffic to mydomain.com/subfolder1 , mydomain.com/subfolder2, blah blah .. will go to corresponding pages as usual.
[Friday, September 11, 2009
|
1 comments
]
Popular Posts
- Mysql query for searching a value, add weightage on the number of occurances and sort based on the weight-age
- How to add or remove WWW on URLs using htaccess.
- Elgg : The most popular open source social networking platform
- php questions
- Jquery based dynamic adding and removal of html elements.
- question regarding socket
- Tips on error 'Allowed memory size of xxx bytes exhausted'
- creating dynamic elements in HTML using Javascript.
- Contact Me
- php questions