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

I'm sure I'm missing a trick here but I can't work out how to remove the trailing slash from a file name in a URL using an Apache RewriteRule.

My URL would be something like this:

www.mysite.com/dynamic_folder_name/index.php/

I need the URL to become

www.mysite.com/dynamic_folder_name/index.php

Any help would be appreciated.

Cheers

share|improve this question
    
edited your question for clarity. –  Massimo Jun 17 '10 at 13:37

1 Answer 1

up vote 3 down vote accepted

Where do you want to do this?

In an Apache rewrite rule?
In a PHP page?
In a bash script?

Plase specify...


Update

RewriteRule. Ok. This should do what you need:

RewriteRule ^(.+)/$  /$1 [R=301,L]
share|improve this answer
    
Sorry, as an apache rewrite rule, so a .htaccess file –  eek Jun 17 '10 at 13:25
    
...why the downvote?!? –  Massimo Jun 17 '10 at 13:28
    
hmm wasn't me :/ –  eek Jun 17 '10 at 13:29
2  
One more example of why people should have to leave a comment when down-voting (even if that comment is anonymous). –  Chris S Jun 17 '10 at 14:15
1  
@Massimo the RewriteRule only says to remove the slash, but if the DirectorySlash directive is set to "ON", which is the default, it would cause them to each override the other (ie. a loop). See httpd.apache.org/docs/2.0/mod/mod_dir.html#directoryslash –  matthew Jun 17 '10 at 18:07

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.