willium
willium

Reputation: 2128

Mod Rewrite Help

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 trouble getting this to work, as so far, I only really know how to do mod rewrite with ONE variable.

Thanks in advance.

Upvotes: 0

Views: 52

Answers (1)

jwueller
jwueller

Reputation: 31006

[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]

Upvotes: 1

Related Questions