Blog Image

How to redirect domain to other directory on the same domain

Open the .htaccess file of your root directory
of your project and add the following line.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^http://someDomainName.com [NC]
RewriteCond %{HTTP_HOST} !^http://www.someDomainName.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteCond %{REQUEST_URI} !^/someOtherDirectory/
RewriteRule ^(.*)$ /someOtherDirectory/$1

Then restart your apache

Usage :
Suppose your project is placed in some other directory
other than the default web directory then you can redirect
your request to that directory for example

Your actual project URL is
"http://someDomaiName/someDirectory/fileName"
and you want that your URL should resemble like
"http://someDomaiName/fileName"
then the above .htaccess rule will do the same.



Author: admin

Vinod Ram has been in Software Industry since 2006 and has experience of over 16 years in Software Development & Project Management domain specialised majorly in LAMP stack & Open Source Technology, building enterprise level Web based Application, Large Database driven and huge traffic Websites and Project Management. He loves to write information articles and blog to share his knowledge and experience with the outside world and help people to find solution for their problems.