繁体   English   中英

如何在网址中添加斜杠? mod_rewrite的

[英]How to add slashes in the url? mod_rewrite

我希望通过用斜杠分隔元素来获得一个不错的seo友好url。 我尝试了几个.htaccess代码,但对我没有用。 我正在使用get方法获取值,并且它运行正常。 我想像下面提到的那样更改网址。 如果有人知道如何更改此设置,请帮助我完成此操作。

来自:

 http://localhost/new/index.php?page=1&per-page=9

至:

 http://localhost/new/index/page/1/per-page/9

在您的Root / .htaccess中尝试一下

RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php\?page=([^&]+)&per-page=([^\s]+) [NC]
RewriteRule ^ /new/index/page/%1/per-page/%2? [NC,L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^new/index/page/([^/]+)/per-page/([^/]+)/?$ /new/index.php?page=$1&per-page=$2 [NC,L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM