...

View Full Version : Simple mod_rewrite problem



Bobafart
12-28-2007, 05:13 AM
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/index.php?newsCategory=science

instead I get an error 404

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

the mod_rewrite:



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 :(



Options +FollowSymLinks
SecFilterInheritance Off

RewriteEngine On
RewriteRule ^foobar/([^/]+)/?$ /newscategories/index.php?newsCategory=$1 [QSA,L]

help would be appreciated

thanks

Apostropartheid
12-28-2007, 04:46 PM
This is what I would do:

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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum