#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    111
    Rep Power
    4

    Mod_rewrite - how to i do domain.com/abc point to abc.html?


    Hi. I want to do mod_rewrite so when people go to domain.com/abc it will actually look for file abc.html on root directory?

    I think it's like this.

    RewriteRule ^abc$ abc.html


    That should be right? But when I put just this line on a new file and save it as .htaccess then it still doesn't treat it as html file on browser.

    Do I need additional lines on my .htaccess file?
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,128
    Rep Power
    9398
    If you want to hide file extensions in general,
    Code:
    Options +MultiViews
    Otherwise you need a RewriteEngine directive to turn on URL rewriting.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    111
    Rep Power
    4
    Originally Posted by requinix
    If you want to hide file extensions in general,
    Code:
    Options +MultiViews
    Otherwise you need a RewriteEngine directive to turn on URL rewriting.
    So do I just put your 1 line on the .htaccess file?

    I don't want to hide extension for all files. I just want one file to have the way I want.
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,128
    Rep Power
    9398
    Just that one abc file? Nothing else? Odd. The Options thing will allow it for all files so then don't use that.
  8. #5
  9. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,127
    Rep Power
    4304
    You need to put "RewriteEngine On" before any other mod_rewrite directives.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).

IMN logo majestic logo threadwatch logo seochat tools logo