大家好,小弟初学PHP,Apache,在此求一份.htaccess URL重写规则,望赐教!我希望实现如下url重写:
http://domain.com/test/123/456/789/ --> http://domain.com/test.htm
http://domain.com/test/abc/efg/ --> http://domain.com/test.htm
http://domain.com/test/{arbitrary1}/{arbitrary2}/{arbitrary3}/.../ --> http://domain.com/test.htm
url里面的test是一个关键字,一定出现在HOST后面,服务器上并没有test这个folder,所有从test出发的请求全部重定向(不是301,对client而言一律得到200或304)到根目录下的test.htm,QueryString不需要.
我写了如下代码,发现重定向时会变成(test/123/456/ -> test.htm/123/456/),我不要后面的123/456,直接是test.htm就可以了。
RewriteEngine on
RewriteBase /
RewriteRule ^test/(.*) test.htm