mod重写问题?

hal*_*sed 1 apache mod-rewrite

我使用mod_rewrite时遇到问题.这就是我正在使用的

Options +FollowSymLinks
RewriteEngine on
RewriteRule pc/$ /pc.php
Run Code Online (Sandbox Code Playgroud)

http://www.example.com/pc/重写为http://www.example.com/pc.php.
这工作得非常好,但是当我访问http://www.example.com/news/today-in-pc/这样的域时,它显示的是pc.php页面.
我在这里做错了什么,如何消除这个问题?谢谢

Gre*_*reg 6

您需要将匹配锚定到URL的开头:

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

# If you're using httpd.conf
RewriteRule ^/pc/$ /pc.php
Run Code Online (Sandbox Code Playgroud)