0

I am trying yo remove the trail slash from an url with this pattern

http://localhost/~francesco/mycms/about/

to make it

http://localhost/~francesco/mycms/about

I have tried lots of rules but no one is working for me.

My rewrite rule is this by now

Options +FollowSymLinks <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /~francesco/mycms/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)$ index.php?page=$1 [L] </IfModule> 

Hope someone can help me!

2

1 Answer 1

1

Try placing this rule

RewriteRule ^(about)/$ $1 [L,R=301,NC] 

just after

RewriteBase /~francesco/mycms/

If you want to work for any first level directory following the RewriteBase i.e. http://localhost/~francesco/mycms/[anything-here]/ use

#exclude the /~francesco/mycms/admin/directory RewriteCond %{REQUEST_URI} !^/admin/ [NC] RewriteRule ^([^/]+)/$ $1 [L,R=301,NC] 
Sign up to request clarification or add additional context in comments.

3 Comments

It works fine until i try to access the /admin directory, it tells safari cannot access the server, if i put it after the if clauses, it works fine to access the admin, but don't work with or without the final slash
@FrancescoZaffaroni what is url for admin: http://localhost/~francesco/mycms/admin/?
@FrancescoZaffaroni I added the exclusion rule above

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.