Welcome Guest, Not a member yet? Register   Sign In
.htaccess and trailing slash
#1

[eluser]sehummel[/eluser]
In my config file, I have:

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

Here is my .htaccess:

Code:
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
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.
#2

[eluser]Daniel Moore[/eluser]
What version of CI?
#3

[eluser]Madmartigan1[/eluser]
The suffix will only be appended on urls generated by CI, and is not required. There is not redirect to the suffixed url or anything like that. So, say you are using the "html" extension:

/services/networking.html will work
/services/networking will also work

If you use the anchor() function, pagination, or anything else that generates urls, it should be working. Otherwise, you have to suffix the links yourself.

If you want to force the extension, you'll need to do a redirect from your .htaccess
#4

[eluser]sehummel[/eluser]
@madmartigan1 -- Does that mean it doesn't work for URIs generated by URI routing. I can't even get it to append .html. If I need to change my .htaccess, can you help me with that, or at least point me in the right direction?

I tried to add the trailing slash to a URI in URI routing, but CI didn't like that.
#5

[eluser]Madmartigan1[/eluser]
Tell me what exactly it is that you're trying to do?

What are you doing? (post your code)
What do you expect to happen?
What actually happens? (post your output)

Be detailed.
#6

[eluser]sehummel[/eluser]
The code is above. I'm not sure what I can post. Here is the actual path of my file:

domain.com/news

Here is the route I want it to have:

Code:
domain.com/news-and-events/

I can get domain.com/news-and-events by doing:

Code:
$route['news-and-events'] = "news";

But it breaks when I try to do:

Code:
$route['news-and-events/'] = "news";
The address bar will only output

Code:
domain.com/news-and-events

I get a 404 error with the second route.
#7

[eluser]n0xie[/eluser]
Maybe this helps: http://farinspace.com/codeigniter-htaccess-file/




Theme © iAndrew 2016 - Forum software by © MyBB