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
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post

    Simple mod_rewrite problem

    I thought this would be a simple solution .. but it doesn't work

    keep getting an error 404


    If the user clicks the link <a href="http://www.foo.com/science/">click me</a> I want it to execute this script: http://www.foo.com/newscategories/in...tegory=science

    instead I get an error 404

    there is no actual directory called "science" on my server

    the mod_rewrite:

    Code:
    Options +FollowSymLinks
    SecFilterInheritance Off
    
    RewriteEngine On
    RewriteRule ^/([^/]+)/?$ /newscategories/index.php?newsCategory=$1 [QSA,L]
    The above code keeps giving a 404 error.

    ------------

    Interestingly the below code works.. however I don't want to URL http://www.foo.com/foobar/science

    Code:
    Options +FollowSymLinks
    SecFilterInheritance Off
    
    RewriteEngine On
    RewriteRule ^foobar/([^/]+)/?$ /newscategories/index.php?newsCategory=$1 [QSA,L]
    help would be appreciated

    thanks

  • #2
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    This is what I would do:
    Code:
    RewriteEngine On
    RewriteRule ^([A-Za-z]+)(/)?$ /newscategories/index.php?newsCategory=$1 [R]
    Although I'm not an expert at regular expressions =P

    And if you MUST use your way, why don't you just change foobar to news?
    Last edited by Apostropartheid; 12-28-2007 at 04:50 PM.


  •  

    Posting Permissions

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