我有以下网址:
1) http://www.example.com/?page=2
2) http://www.example.com/my-photos-folder?page=3
此处页码将按顺序增加(页面= 1,页面= 2,页面= 3 .....)。
“my-photos-folder”可以是“my-images-folder”或“Nice-photos”等。
我想得到什么:
1) http://www.example.com/page/2
2) http://www.example.com/my-photos-folder/page/3
我的.htaccess有以下规则:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^page\/(.*)$ index.php?page=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?kohana_uri=$1 [QSA,PT,L]
RewriteRule ^$ index.php?kohana_uri=$1 [QSA,PT,L]
RewriteRule ^index.php/(.*) $1 [QSA,R,L]
</IfModule>
任何专家都可以建议我需要添加哪些规则,以便实现我想要的结果。提前谢谢。
答案 0 :(得分:1)
在RewriteEngine On
行之后添加theese行:
RewriteRule ^page\/(.*)$ index.php?page=$1 [L]
RewriteRule ^(.*)\/page\/(.*)$ $1?page=$2 [L]
答案 1 :(得分:1)
@develroot
RewriteRule ^page\/(.*)$ index.php?page=$1 [L] //This is working fine for homepage
RewriteRule ^(.*)\/page\/(.*)$ $1?page=$2 [L] //this rule still not working on directory level.
第二个仍有问题。请考虑已经存在的规则。[我已经更新了问题 - 添加了你的第一条工作正常的规则。]