开发者

Mod Rewrite Help

开发者 https://www.devze.com 2023-01-27 13:10 出处:网络
I have some basic knowledge of Mod Rewrite, but I can\'t figure this out! I want http://example.com/posts/[NAME]/~[ID]/#[PAGE]

I have some basic knowledge of Mod Rewrite, but I can't figure this out!

I want

http://example.com/posts/[NAME]/~[ID]/#[PAGE]

and be able to get it like $_GET['name'], $_GET['id'], and $_GET['page']

NAME is a en escaped string, so it allow A-Za-z1-9 and the special characters ?_-! (and replaced with %20, etc. , any amount of characters.

ID is a-zA-Z1-9, any amount of characters.

PAGE is a number, any amount of characters.

Also, I'm trying now: [NAME]-[ID]/[PAGE]/ but I don't need to $_GET['name'] in this one.

Having t开发者_JAVA技巧rouble getting this to work, as so far, I only really know how to do mod rewrite with ONE variable.

Thanks in advance.


[NAME]/~[ID]/#[PAGE]:

RewriteEngine On
RewriteRule ^posts/([^/]+)/\~([^/]+)/#(\d+)$ your_file.php?name=$1&id=$2&page=$3 [QSA,L]

[NAME]-[ID]/[PAGE] without $_GET['name']:

RewriteEngine On
RewriteRule ^posts/[^\-]+\-([^/]+)/(\d+)$ your_file.php?id=$1&page=$2 [QSA,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号