Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    New Zealand
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trouble with mod_rewrite

    Hi there, I am running the following .htaccess file in the root directory of my site:

    # Customized server error messages:
    ErrorDocument 404 /index.php

    # Rewrite rules
    RewriteEngine on
    RewriteRule ^/books/([0-9]+)$ /books/view.php?b=$1


    The customised error page shows up fine but the rewrite rule just keeps giving me 404's. I am trying to replace:

    /books/view.php?b=130

    with

    /books/130

    Any help would be appreciated!
    eTheory - the theory of revolution

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    UK
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this instead:

    RewriteRule ^books/([0-9]+)$ /books/view.php?b=$1

    Your regex looks fine, just need to take out the leading / when using ^ as I don't think apache passes this along to mod rewrite


  •  

    Posting Permissions

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