.htaccess重写多个规则不起作用

时间:2012-07-19 02:11:32

标签: apache .htaccess mod-rewrite

我已经阅读了有关如何进行重写的几个资源,并在以下方面取得了一些成功:

RewriteEngine On
RewriteBase /~me/website.net/html/
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ property.php?property=$1

......我可能不需要告诉你转换......

http://imac-i3.local/~me/website.net/html/property-name

...到......

http://imac-i3.local/~me/website.net/html/property.php?property=property-name    

无论我读了多少,我都无法弄清楚我需要做的下一阶段转换...

http://imac-i3.local/~me/website.net/html/1
http://imac-i3.local/~me/website.net/html/property/property-name

要...

http://imac-i3.local/~me/website.net/html/index.php?page=1
http://imac-i3.local/~me/website.net/html/property.php?property-name

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

您希望将规则从RewriteRule ^(.*)$ property.php?property=$1更改为:

RewriteRule ^property/(.*)$ property.php?property=$1 [L]

并为分页添加此内容(可以在您已有的规则之后):

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)$ index.php?page=$1 [L]