Q:

Get last element between slashes with .htaccess

Assuming a string like http://domain.com/aaaa/bbb/ccc/ddd/
I want to use a .htaccess file to get the last element between slashes, in this case ddd.
I am using:
RewriteRule (.*)/$ ?pt=$1 [L] 

But it is not working.

A:

Try this regex:
([^/]+)/$ ?pt=$1 [L]

