Forum Moderators: phranque
Say I have a URL like this:
[example.com...]
or simply
[example.com...]
What is important here is the last folder. That is what I need to get. However, there could by any number of folders before LastFolder. Is there anyway to retrieve the name of the last folder?
Basically, I'm look for something like
RewriteRule ^directory/...any_number_of_folders_here.../(.*)/ index.php?dir=$1
Thanks for the help.
I assume you're asking about code for use in .htaccess as opposed to httpd.conf. If so, try this:
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteCond %{REQUEST_URI} /([^/]+)/?$
RewriteRule .+ /index.php?dir=%1 [L]
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteRule /([^/]+)/?$ /index.php?dir=$1 [L]
Jim