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
- How to add or remove WWW on URLs using htaccess.
- Mysql query for searching a value, add weightage on the number of occurances and sort based on the weight-age
- Pattern Matching in mysql
- How to create a plugin in elgg.
- php questions
- How to find out the Mysql storage engine type of a table.
- Running a perl script from PHP
- function to check whether the year given is a leap year or not
- Share your knowledge
- Elgg : The most popular open source social networking platform
1 comments
cool Juban jon
Post a Comment
Please put your comments here. your questions, your suggestions, also what went wrong with me.