Thursday 2 January 2014

Redirecting Virtual urls like subdomain names to a subfolder using htaccess file

Here I will explain how to redirect virtual urls similar to subdomain names to a subfolder using .htaccess file.
I will explain it with the help of an example.Iam working on a project named blogger.com.
. Here users can create their own blog urls..  if users name is robert. He can create a url like robert.blogger.com. Here actually we are not creating subdomains manually. If we create so then we have to do it manually for all users.that will go out of control. so what I do is created a folder named user where all requests will execute & it act as a subdomain. Here I wrote this code for htaccess.just try it..


Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.blogger.com
RewriteCond %{HTTP_HOST} ([^.]+)\.blogger.com
RewriteRule ^(.*) user/user.php?username=%1


IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName blogger.com



No comments:

Post a Comment