SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Mod rewrite not working on localhost

    I am using the following code in .htaccess

    Code:
    Order deny,allow
    allow from 127.0.0.1
    deny from all
    
    # Enable mod_rewrite, start rewrite engine
    RewriteEngine on
    #
    # Redirect "foo.html" to google.com
    RewriteRule ^foo\.html$ http://www.google.com/ [R=301,L]
    and have a foo.html file as "test ok"

    When i write http://localhost/foo.html it just prints "test ok" AND NOT REDIRECT TO google.com . Now what to do to run the mod rewrite on localhost?

  2. #2
    SitePoint Evangelist AlienDev's Avatar
    Join Date
    Feb 2007
    Location
    UK
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you need to add this to htaccess:
    allow from localhost
    Me on StackOverflow | Blog & personal website.

    I mostly use: PHP, Java, JavaScript, Android.

  3. #3
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post

    Quote Originally Posted by AlienDev View Post
    I think you need to add this to htaccess:
    allow from localhost
    I added allow from localhost

    still not working!

  4. #4
    SitePoint Evangelist AlienDev's Avatar
    Join Date
    Feb 2007
    Location
    UK
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:
    RewriteRule ^/?foo\.html/?$ http://www.google.com/ [R=301,L]
    Me on StackOverflow | Blog & personal website.

    I mostly use: PHP, Java, JavaScript, Android.

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    kh,

    I suspect that you do not have mod_rewrite enabled on your test server (localhost). That said, I would recommend that you have a read of the tutorial Article linked in my signature and specifically the Setup and Test sections. From your apparent limited knowledge of regex (IMHO), you should read the regex section, too.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •