sehummel
sehummel

Reputation: 5568

.htaccess and trailing slash in CodeIgniter

In my config file, I have:

$config['url_suffix'] = "/"; 

Here is my .htaccess:

    Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI}      ^.+[^/]$
RewriteRule ^(.+)$              $1/   
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 

When I load a page, I don’t get the trailing slash. I am using URI routing, but even when I go to the actual path of the controller/view, I still don’t get the trailing slash.

What am I doing wrong? I tried removing the slash after the .php in the last line of the .htaccess, but that didn’t do it.

Even if I add “.html” as my URL suffix, it doesn’t get added. And that’s not in my .htaccess.

If I try to make $route['news-and-events'] = "news"; this instead: $route['news-and-events/'] = "news"; I get a 404 error

EDIT: With the above .htaccess I get an error that I am using disallowed characters, even when I add "/" to my allowed characters string in the config file.

Upvotes: 0

Views: 2753

Answers (1)

sidai
sidai

Reputation: 11

Found a one that worked for me, Imported my Blogger posts to my Wordpress, and then my back links didn't work, so I just replaced my .htaccess with this example, check it out!

http://www.high-on-it.co.za/2011/02/removing-trailing-html-from-url/

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_URI} \.html$

RewriteRule ^(.*)\.html$ $1 [R=301,L]

RewriteRule ^index\.php$ – [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

Upvotes: 1

Related Questions