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
- Help with codeignitor
- Creating Custom Module in VtigerCRM
- Contact Me
- Creating Google map and adding markers ans polyline on it
- PHP Question and answers
- Mysql Questions
- Add/Remove text control using javascript
- function to check whether the year given is a leap year or not
- Random password generation :using ajax and jquery
- Css