04 November 2010

Set Folder Name to be working as Primary Domain Name

To make a new folder as the default domain name , you need to write some code in .htaccess file

For example :
if your domain name is www.yourweb,com
and you want to set a folder named ver1 as primary directory ,
then you need to write some code in .htaccess file to redirect to your ver1 folder as primary domain.

To do this , create a file names .htaccess in the public_html/ directory .
Write the following code in .htaccess file .
Change <DOMAIN> to your domain name .
Change <SUBDIRECTORY> to the path of that folder you like to set to be primary directory.

-------------------------------------------------------------------------------------
.htaccess
-------------------------------------------------------------------------------------
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} <DOMAIN>
RewriteCond %{REQUEST_URI} !^/<SUBDIRECTORY>/(.*) [NC]
RewriteRule ^(.*)$ /<SUBDIRECTORY>/$1
-------------------------------------------------------------------------------------


This code after changing will look like this :
-------------------------------------------------------------------------------------
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} www.yourWebsite.com
RewriteCond %{REQUEST_URI} !^/ver1/(.*) [NC]
RewriteRule ^(.*)$ /ver1/$1
-------------------------------------------------------------------------------------

(If you found this article useful then share with your friends.)

No comments: