分页重写规则

时间:2013-02-01 00:33:27

标签: regex .htaccess mod-rewrite url-rewriting

我可以在.htaccess文件中添加什么重写规则来制作

domain.com/directory/index.php?page=$page

重写为

domain.com/directory/2

2 个答案:

答案 0 :(得分:0)

RewriteRule /directory/(\d+) /directory/index.php?page=$1

答案 1 :(得分:0)

你可以试试这个:

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

无声地映射

http://domain.com/directory/PageNumber

要:

http://domain.com/directory/index.php?page=PageNumber

directoryindex.php被假定为固定字符串。

对于永久重定向,请将[L]替换为[R=301,L]