我可以在.htaccess文件中添加什么重写规则来制作
domain.com/directory/index.php?page=$page
重写为
domain.com/directory/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
directory
和index.php
被假定为固定字符串。
对于永久重定向,请将[L]
替换为[R=301,L]