Well… I see a lot of questions regarding SEO friendly URLs, and also regarding the problem with URLs that have trailing slashes which show the same content as the URLs without trailing slashes. Although I really hope that the search engines are smarter than treating those URLs as duplicate content, I feel there is the need to know how to redirect them to the non-trailing slashes URLs.
So here it is. You open .htaccess, and you should have in it the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
RewriteEngine On SetEnvIf Host yoursite.tld$ CI_ENV=production SetEnvIf Host test.yoursite.tld$ CI_ENV=testing SetEnvIf Host localhost$ CI_ENV=development # remove trailing slashes from URLs RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.*)/$ RewriteRule ^(.+)/$ $1 [R=307,L] RewriteCond $1 !^(index\\.php|resources|robots\\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L,QSA] |
This should work for anything, not just CodeIgniter. Hope this helps…