Treehouse: Grow your CSS skills. Land your dream job.

This should be simple :(

  • # December 20, 2009 at 4:07 pm

    Hi, i have read about 10 different tutorials and searched the forums on this site to help me but i still can’t get it to work when everyone else makes it look so simple!
    I have a site with only one page, index.php
    this address
    i want to be able to add somthing onto the end of this url so
    And the site goes to the index page rather than a 404 error page as the page does not exist.
    Now all the tutorials i have read say the same thing, use .htaccess file, but i can’t get it to work and i have no idea why.
    This is my .htaccess file at the moment.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^ [NC]
    RewriteRule ^(.*)$$1 [L,R=301]

    This works as it should but can someone please help me with the rest of the code?

    Many Thanks

    # December 20, 2009 at 5:25 pm

    htaccess junk is never simple.

    Try adding a $ to the end of your first line: ^$ [NC]

    # December 20, 2009 at 6:03 pm

    Thanks for the reply – the code i have posted is the code that is already in my file, it all works perfectly its the other part that i mentioned originally that i can’t get to work.
    THe code thats’s already there just forces the address to be, http://www.mysite rather than http://mysite

    # December 20, 2009 at 6:24 pm

    Ah, I must have misunderstood your original post.

    Here’s some code that I got to work for one of my sites which basically pointed the root address to a subfolder, maybe you can use something from it:

    RewriteEngine on
    Options +FollowSymlinks
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^(www.)?$ [NC]
    RewriteCond %{REQUEST_URI} !^/mysitesubfolder/

    # Don’t change these lines.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # Change ‘subfolder’ to be the folder you will use for your main domain.
    RewriteRule ^(.*)$ /mysitesubfolder/$1 [L]

    # Change to be your main domain again.
    # Change ‘subfolder’ to be the folder you will use for your main domain
    # followed by / then the main file for your site, index.php, index.html, etc.
    RewriteCond %{HTTP_HOST} ^(www.)?$ [NC]
    RewriteRule ^(/)?$ mysitesubfolder/index.php [L]

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.