Reputation: 41
Im trying to rewrite-redirect a set of URLs like this
From this: misitio.com/categoria1 --> To this --> misitio.com/categoria1.html
so far ive got one working match, this rewrites first level subfolder:
RewriteRule ^categoria1/(\w+)$ $1.html [QSA,L]
My goal now is , given whatever subfolders deep the url input is, i'd rewrite the last subfolder as a single html file, like this:
From this: misitio.com/categoria1/categoria2/categoria3 --> to this: misitio.com/categoria3.html
From this: misitio.com/categoria1/categoria2/categoria3/categoria4/categoria5/ --> To this --> misitio.com/categoria5.html
I know ive got to use conditionals, a little help here will be appreciated :D
Thanks in advance!
Upvotes: 0
Views: 314
Reputation: 41219
To rewrite - http://example.com/cat1cat2/cat3/cat4/cat/5/
to
You can use the following RewriteRule :
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /$5.html [NC,L]
Upvotes: 1