Pretty urls (remove file extension, fake folders)

Everything related to the visual and coding aspects of websites.
Lysianthus
Posts: 23
Joined: Sun May 17, 2015 9:34 pm
Location: Philippines
Contact:

Re: Pretty urls (remove file extension, fake folders)

Post by Lysianthus »

Another trick I would suggest is to simply catch any character that is not a forward slash, instead of having to declare the characters manually (0-9a-zA-Z), so:

Code: Select all

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ $1.php?cat=$2&page=$3 [L]
The ^ means "not", so [^/] means "anything that is NOT /". :ok:
Affelius (creative) ☆ Asclaria (network) ☆ Lysianthus (personal)
Masao
Host
Posts: 579
Joined: Thu Jun 16, 2011 12:29 am
Contact:

Re: Pretty urls (remove file extension, fake folders)

Post by Masao »

Oh yes, that is a very good point. Catching all would be better for a "fits all" approach. I just personally like small whitelists over blacklists for paranoid security reasons.
THE FATE OF DESTRUCTION IS ALSO THE JOY OF REBIRTH.
Post Reply