Grow your CSS skills. Land your dream job.

A very basic Mod Rewrite question

  • # August 29, 2010 at 2:27 am

    I have a URL http://example.com/gallery/familypics.php. I want this URL to be shown as http://example.com/familypics on the visitor’s web URL bar. I wnat to use mod rewrite for this. Please tell me how can I do it?

    # August 29, 2010 at 8:19 am

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php

    put this on your htaccess file. if it’s not create one. this will rewrite all short url’s to php ones. remember if you have test.html then it will be not found as if you type
    http://www.example.com/test then it will find test.php not test.html

    # August 30, 2010 at 11:09 am

    @hardik, I don’t think that will get rid of /gallery from the url though, will it?

    # September 2, 2010 at 3:54 am

    @betzster
    yep for that this line of code will be required….



    rewritebase gallery/

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".