Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 works, but anything after /PLUGINNAME/xxx defaults to the /index.php.

share|improve this question

migrated from Oct 27 '12 at 14:43

This question came from our site for professional and enthusiast programmers.

up vote 0 down vote accepted

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]
share|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 posting your answer, you agree to the privacy policy and terms of service.

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