Hi, I am tring a mod rewrite to make it so all urls that need a trailing slash get it. If entered (www.mydomian.com/alabama changes to www.mydomian.com/alabama/) The following code works but also adds the "/" to urls with the .html etc.. e.g.(www.mydomian.com/contactus.html is now www.mydomian.com/contactus.html/) What am I doing wrong? RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !example.php RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ http://www.mydomain.com/$1/ [L,R=301]
Pretty tricky eh! Here is a workaround that you can do in your index.php file $uri = $_SERVER['REQUEST_URI']; $check1 = strrev($uri); $check2 = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."/"; if ($check1(0) != "/") { header ("location: $check2"); // Do not use single quote here } PHP: But, this 'may' impact ur SEO, we are using header change request, so make sure, this is above ENTIRE code! PS: I haven't tried the code but, it just might work