ozestretch Posted January 29, 2010 Share Posted January 29, 2010 Currently I add trailing slash to all directories so domain.com/666 redirs to domain.com/666/ I have a function that looks for '+' domain.com/666+ or domain.com/666+all but I do not want these urls to add a trailing slash So that works fine.... Issues is if a trailing slash is added (by user or whatever) at the end of a link like domain.com/666+/ domain.com/666+all/ I want it removed. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]|/)$ RewriteCond %{REQUEST_URI} ([^+-+all])$ RewriteRule (.*)$ http://domain.com/$1/ [R=301,L] I would post what I tried but I kept deleting and starting over. Quote Link to comment Share on other sites More sharing options...
ozestretch Posted January 29, 2010 Author Share Posted January 29, 2010 okay so this isn't what I needed either RewriteCond %{REQUEST_URI} ([^+-+all])$ this is good as the only links with a + are desired to not have trailing slash RewriteCond %{REQUEST_URI} ([^+])$ but the first method means if there is an a or an l it no work... help x 2 now lol thanks Quote Link to comment Share on other sites More sharing options...
oni-kun Posted January 29, 2010 Share Posted January 29, 2010 Try this: #remove trailing slashes RewriteCond %{HTTP_HOST} !^\.yourdomain\.com$ [NC] RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L] Quote Link to comment Share on other sites More sharing options...
ozestretch Posted January 29, 2010 Author Share Posted January 29, 2010 thanks, unfortunately it doesn't offer what I need. domain.com domain.com/xxxxx to have trailing slash domain.com/xxxxx+ and domain.com/xxxxx+all to have no trailing slash so far it works except the trailing slash is still added to domain.com/xxxxx+all RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]|/)$ RewriteCond %{REQUEST_URI} ([^+])$ RewriteRule (.*)$ http://domain.com/$1/ [QSA,R=301,L] # RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{HTTP_HOST} !^domain.com$ [NC] RewriteRule ^(.*)$ http://domain.com/$1/ [QSA,L,R=301] Quote Link to comment Share on other sites More sharing options...
ozestretch Posted January 29, 2010 Author Share Posted January 29, 2010 Sorted - thnks corz RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]|/)$ RewriteCond %{REQUEST_URI} ([^+])$ RewriteCond %{REQUEST_URI} !([a-zA-Z0-9]\+(all))$ RewriteRule (.*)$ http://domain.com$1/ [QSA,R=301,L] # RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{HTTP_HOST} !^domain.com$ [NC] RewriteRule ^(.*)$ http://domain.com/$1/ [QSA,L,R=301] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.