1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to set localhost to be mod rewritten

Discussion in 'Apache' started by DavidAusman, Jan 13, 2006.

  1. #1
    Hi
    I just learn how to mod rewrite from a member here 'Nintendo' and was trying it to apply mod_rewrite on my localhost.

    Is there any setting needed in apache httpd.conf to enable mod rewrite?
    Any help is appriciated
    **Thanks
     
    DavidAusman, Jan 13, 2006 IP
  2. SEbasic

    SEbasic Peon

    Messages:
    6,317
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can't you just create a .htaccess file?

    I don't usually test locally, so I may be wrong.
     
    SEbasic, Jan 13, 2006 IP
  3. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You must load the module rewrite_module in the httpd.conf file.
     
    Dejavu, Jan 13, 2006 IP
  4. DavidAusman

    DavidAusman Peon

    Messages:
    399
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I had used .htaccess but no luck, and then I also try to uncomment #LadModule in httpd.conf and still dont work.

    Does anyone know what to do to make it work locally? I dont use my local machine to go online. Im afraid of those viruses get into my compy :(
    Thanks
     
    DavidAusman, Jan 13, 2006 IP
  5. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You must uncomment the line
    Make sure the .htaccess file is in the directory your looking at (probably the root)
    If it still dont work, change the line
    to
     
    Dejavu, Jan 13, 2006 IP
  6. DavidAusman

    DavidAusman Peon

    Messages:
    399
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Still no luck
    I had uncomment
    #LoadModule rewrite_module
    #AddModule mod_rewrite.c
    and set
    AllowOverride none to AllowOverride all
     
    DavidAusman, Jan 13, 2006 IP
  7. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Did you restart apache? There are more than 1 place where you can change AllowOverride, try changing them all to AllowOverrid All

    Also, put an empty file with just the following info
    <?php
    echo phpinfo();
    ?>
    and make sure that mod_rewrite is one of the modules that gets loaded.
     
    Dejavu, Jan 13, 2006 IP
  8. DavidAusman

    DavidAusman Peon

    Messages:
    399
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yes I had restart my server and had change all AllowOverride. There are about 7 AllowOverride.

    If the mod_rewrite had been successfully enable, is there any method I can test? Since Im new to apache and mod_rewrite, probably there is something I missed out.

    When I try to access .htaccess which is located at htdocs/test_file in the browser http://localhost/test_file/.htaccess It shows FORBIDDEN message which seems like it had already enabled.

    Probably something is wrong with my htaccess, is there any special line that had to be included?
    Thanks
     
    DavidAusman, Jan 13, 2006 IP
  9. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #9
    Do a little test with the index page...

    At domain.com/.htaccess

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^wacko\.html$ index.html [L]

    with index.html being the file name of the index page.

    Then go to

    domain.com/wacko.html and see what you get.
     
    Nintendo, Jan 13, 2006 IP
  10. DavidAusman

    DavidAusman Peon

    Messages:
    399
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #10
    This is what I just did:

    I create a folder named test in htdocs which is accessible through http://localhost/test

    And then I create index.html and .htaccess with the lines you provide.

    When I open up http://localhost/test/wacko.html , I get an internal error message. While for my own website which I build on local machine shows 404 error message when I try to access mod_rewritten URLs. I used the same .htaccess on my internet server and does not seems to go wrong

    Does my machine had already enable mod_rewrite, or probably my .htaccess?
    Thanks
     
    DavidAusman, Jan 13, 2006 IP
  11. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #11
    If it's your own computer, I have no idea. I've only used mod_rewrite on domain.com URLs, not localhost!!!
     
    Nintendo, Jan 13, 2006 IP
  12. kgtrip

    kgtrip Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Hi guys, just came across this thread while I was facing the same problem, however I found the solution for localhost over your local computer:

    1. You have to uncomment the load mod rewirte lines over the conf file (as was explained before)
    2. replace "AllowOverride None" to "AllowOverride All" only in 1 line (not all the 7 lines it appears). You have to change it over the section it talks about .htaccess:

    Hope that would help someone:)
     
    kgtrip, Feb 4, 2006 IP
  13. rziddha

    rziddha Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    http://groups.google.com/group/alt.apache.configuration/browse_thread/thread/3c567d8d09bffb4a/3948234ede12ab4d?lnk=raot
     
    rziddha, Feb 16, 2006 IP
  14. apachehtaccess

    apachehtaccess Guest

    Messages:
    82
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #14
    apachehtaccess, May 10, 2007 IP
  15. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #15
    apachehtaccess, is mod_rewrite supposed to be able to work on localhost? Every time I see some one post about trying to get it to work there, it never works. I have yet to see some one get it to work there.
     
    Nintendo, May 10, 2007 IP
  16. apachehtaccess

    apachehtaccess Guest

    Messages:
    82
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Yes mod_rewrite works fine on localhost, there are just a few little quirks.

    Instead of trying to use localhost, why not use 127.0.0.1 often that will work much better.
     
    apachehtaccess, May 16, 2007 IP
  17. browntwn

    browntwn Illustrious Member

    Messages:
    8,347
    Likes Received:
    848
    Best Answers:
    7
    Trophy Points:
    435
    #17
    This post came up in google for my search for "mod_rewrite on localhost" and the change from "AllowOverride None" to "AllowOverride All" was the perfect solution.

    Thank you 5 year old thread!!!
     
    browntwn, Oct 20, 2011 IP