Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

www.website.com/something

which are using the root folder /index.php

Now I have created plugins within folders:

/plugins/PLUGINNAME/index.php

I want to be able to have URLs like:

www.website.com/plugins/PLUGINNAME/anything/iwant/here

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.

share|improve this question

migrated from stackoverflow.com Oct 27 '12 at 14:43

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

1 Answer 1

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

 
discard

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.