Support » Plugins » Accessing your site from the root URL

  • I posted this on my blog but thought I’d put it here too…

    I’ve seen a lot of people asking how to access their WordPress blog from the root URL and there is some info out there about moving the index.php file from the WordPress folder to the root folder and making some changes to it. There are also lots of replies out there from people who tried this unsuccessfully.

    Here’s some code that you can put in the .htaccess file in your root directory that will do the same thing without modifying or moving any of the WordPress core files. For this example the root URL is shown as domain.ext and the WordPress folder is shown as wpfolder. You will have to change these values to match your own domain name, extension, and WordPress folder name:

    RewriteEngine On
    Options +FollowSymlinks
    RewriteCond %{HTTP_HOST} domain.ext$
    RewriteCond %{REQUEST_URI} !wpfolder/
    RewriteRule ^(.*)$ wpfolder/$1

    Upload the new .htaccess file to the root directory of your web server as a plain text file. You’re done!

    HTH,
    John Nasta
    (johnnasta.com)

Viewing 9 replies - 1 through 9 (of 9 total)
  • p.s. Here are three sites that I put up yesterday & today using the above code. Note that when you are on the home page the WordPress folder name does not show as part of the URL in the browser’s address bar:

    http://prestonsbeat.com

    http://prestonforkids.com

    http://thesnarks.org

    These are all new sites, so they don’t have any content on them yet.

    HTH

    Just as a point of clarification, would you need to create a Symlink anywhere in your webspace in order to get the .htaccess rules to work, or do these rules simply give the illusion (in a browser address bar) that the pages are being served from root, when in fact the really have never been moved (still exist in a sub-directory)?

    I haven’t done anything other than upload the .htaccess file as explained.

    Only the homepage URL omits the WordPress folder name. It shows in the address bar once the user starts clicking around. If for example you go to prestonsbeat.com and click on the Hello World post, the URL in the address bar shows up as

    http://prestonsbeat.com/blog/2009/uncategorized/hello-world/

    (the permalink structure in this case is /%year%/%category%/%postname%/)

    The main advantage of this technique is that your home page comes up at the root URL without modifying or moving any core files.

    Thank you. I just wanted to clarify/confirm if all other site URI’s will still contain the sub-directory in their structure, and that no files/folders are actually moved. The .htaccess rules only disguise the front page URI in the browser address bar.

    Thanks!

    Cj

    The .htaccess rules that I have written make your site accessible from the root URL/URI. It’s much easier and safer than modifying and moving core files. I decided to do this after seeing people respond about how they crashed their site by trying to move and modify the WordPress index.php file.

    Are there any SEO implications doing it that way? I mean, is there a possibility that if mysite.com/blog redirects and 301’s to mysite.com,
    that Googlebot could interpret my content as duplicate links or domain masking?

    You can see I’m not very knowledgeable on this sort of thing, so I really do appreciate your patience.

    Please feel free to ask but I’m honestly not a SEO expert. I don’t think this is considered a 301 redirect or domain masking, but I can’t say whether or not it has any other SEO implications. I’m glad you brought it up because maybe some other people who know more about SEO will be able to clarify that point.

    Ok – Here is what I am trying to do. I would deeply appreciate your help because I think I am trying to do what you describe. I want myURL.com/wordpress/home to just look like myURL.com/home.

    Call my site myURL.com

    wordpress exists in:
    myURL.com/wordpress

    I have subdirectories for each area under wordpress:

    myURL.com/wordpress/home
    myURL.com/wordpress/news
    myURL.com/wordpress/contact

    etc.

    Currently, I have a redirect:

    myURL.com to myURL.com/wordpress/home/index.php

    I added the code you have listed above to the root directory .htaccess file (with all the redirects) and it didn’t seem to affect anything.

    Not sure what is going on.

    here is the code I added to the root .htaccess file

    RewriteEngine On
    Options +FollowSymlinks
    RewriteCond %{HTTP_HOST} MyURL.com$
    RewriteCond %{REQUEST_URI} !wordpress/
    RewriteRule ^(.*)$ wordpress/$1

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Accessing your site from the root URL’ is closed to new replies.