I've been searching for awhile now and haven't found anything that comes close to what I'm trying to accomplish.

Right now my URL's look like this:


which are using the root folder /index.php

Now I have created plugins within folders:


I want to be able to have URLs like:


which are all using /plugins/PLUGINNAME/index.php and not the root directory index.php.

Currently www.website.com/plugins/PLUGINNAME/ works, but anything after /PLUGINNAME/xxx defaults to the /index.php.


this will strip off any characters that come after the plugin folder slash, like anything/iwant/here in your example. Make sure the end is .+ and not .* or you'll go into an infinite redirect loop

RewriteRule ^plugins/([^/]+)/.+ /plugins/$1/ [R=301,NC,L]
| improve this answer | |
  • also, put this rule ABOVE whatever rule you have that sends everything else to /index.php – WebChemist Oct 26 '12 at 6:08
  • remove R=301 if you do not want the actual url to be rewritten in the browser and only forward on the request behind the scenes – WebChemist Oct 26 '12 at 11:12
  • If I remove R=301, it gives me internal server error. But this line is placed at the bottom of my htaccess file. So far this answer is working, I just don't want it to show in the browser URL that it's being redirected – Andrew Oct 26 '12 at 14:27
  • RewriteRule ^plugins/([^/]+)/.+ /plugins/$1/ [NC,L] throws a 500 error? – WebChemist Oct 26 '12 at 16:48
  • Yup. But only on links with /plugins/ in it. This is also now at the top of my .htaccess file: – Andrew Oct 26 '12 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.