Syn Syn - 5 months ago 28
Apache Configuration Question

How do you ignore parts of a URL with Mod Rewrite?

I am using

Mod Rewrite
to create attractive URLs. I am trying to understand how it is possible to ignore parts of a URL?

For example, my original URL was:

And I have written a Mod Rewrite code to turn that into:

RewriteEngine On
RewriteRule ^file/([^/]*)$ /file.php?token=$1 [L]

However, I would like to achieve a URL like:

The random bits on the end serve no purpose (other than decoration). How do I tell Mod Rewrite to ignore this part of the URL?


Just tweak your regex like this

RewriteRule ^file/([^/]+)/?(.*)$ /file.php?token=$1 [NC,L]