我在htaccess中尝试过以下操作,但似乎无法正常工作,
Options +FollowSymLinks +Indexes +MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ $1.php?bid=$2&page=$3 [L]
通过这样做,
http://www.turkish-property-world.com/antalya_apartment.php?bid=4&page=1
应该是
http://www.turkish-property-world.com/antalya_apartment/4/1
答案 0 :(得分:1)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/(.*)/$ $1.php?bid=$2&page=$3 [L,QSA]
RewriteRule ^(.*)/(.*)/(.*)$ $1.php?bid=$2&page=$3 [L,QSA]
答案 1 :(得分:1)
您的规则是正确的,但真正的问题是您使用MultiViews
。把它拿出来用:
Options +FollowSymLinks +Indexes -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ $1.php?bid=$2&page=$3 [L,QSA]
MultiViews
使用选项Apache's content negotiation module
,它在mod_rewrite
之前运行,并使Apache服务器匹配文件扩展名。因此/file
可以在网址中,但它会投放/file.php
。