You are Unregistered, please register to gain Full access.    

Go Back   Webmaster Forums & SEO Internet Marketing Resources > Web Developing & Designing > Programming


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-28-2008, 02:41 PM
sumeet911's Avatar
Member
 
Join Date: Jan 2008
Posts: 68
My Mood:
iTrader: (0)
Friends: (0)
sumeet911 is on a distinguished road
Default Redirecting the root of website to a folder using htaccess

Many people make a common mistake while installing the blogs on their domain,What they do is they install the blog on some folder rather than the root of the website.Hence the address of the blog becomes something like www.mydomain.com/blog without keeping any content on the root of the site (i.e. mydomain.com)

That's not the only case,Many times by misake OR unknowingly they make their whole website on some other folder rather than the root.and It become a mess to again shift the website one tree down

BUT there is one thing which could solve this issue without moving the whole website,That's redirecting the users from the root -> to that folder.

Redirection can be made using META tags or using .htaccess file .Use of .htaccess is recommended in redirection cases as many search engine penalizes for using a META refresh tags( as it is mostly used by keyword spammers)

OH BTW this tutorial is also posted in my blog - Redirecting the root of website to a folder using htaccess

So coming to the point, consider you own a domain "mydomain.com" And you want to redirect all the traffic form "mydomain.com" to "mydomain.com/blog" then use these codes on the .htaccess file on the root (mydomain.com/)

These codes can also be used if you want .. .. . More...to change your default web page to some other internal folder page.(although htaccess default directory can be used)

In all these examples mydomain.com/ is considered as root AND /blog/ is considered as the internal folder

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^$ /blog/ [R=301]
    </IfModule>
OR

Code:
 RewriteEngine on
    RewriteRule ^([/]+)$ blog/$1 [L,R=301]
OR

Code:
RedirectMatch permanent ^/$ http://mydomain.com/blog/
Although I will recommend to use the 1st one.
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:10 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81