views:

32

answers:

1

I am facing a problem using mod_rewrite. This is what I am using

Options +FollowSymLinks
RewriteEngine on
RewriteRule pc/$ /pc.php

to rewrite http://www.example.com/pc/ to http://www.example.com/pc.php.
This is working perfectly fine but, when I go to a domain such as http://www.example.com/news/today-in-pc/ it is showing the pc.php page.
What am I doing wrong here and how can I eliminate this problem? Thanks

+5  A: 

You need to anchor the match to the start of the URL:

# If you're using .htaccess
RewriteRule ^pc/$ /pc.php

# If you're using httpd.conf
RewriteRule ^/pc/$ /pc.php
Greg