CodeIgniter Forums
htaccess help - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: htaccess help (/showthread.php?tid=38960)



htaccess help - El Forum - 02-24-2011

[eluser]kongfjong[/eluser]
Hey out there

As I'm new to Code Igniter, I wanted to make a htaccess file, that removes the index.php? part of the uri. I found the following guide http://codeigniter.com/wiki/mod_rewrite/ which works great.

The thing is though, that I already have a htaccess file with the following content:

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^footballground.dk$
RewriteRule ^(.*)$ "http\:\/\/www\.footballground\.dk\/$1" [R=301,L]

This is content generated by my site-providers control panel, and redirects all requests for footballground.dk to www.footballground.dk as wanted to make sure, that all users arrive at the www version of the domain.

But I'm failing to mix the two different contents and I'm hoping you can help.

So, I still want to get rid of the index.php? part of the uri and still want every user to end up at the www version of the domain Smile


htaccess help - El Forum - 02-24-2011

[eluser]Jaketoolson[/eluser]
Code:
RewriteEngine on

RewriteCond %{HTTP_HOST} ^footballground.dk$
RewriteRule ^(.*)$ "http\:\/\/www\.footballground\.dk\/$1" [R=301,L]  

# Add
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]



htaccess help - El Forum - 02-24-2011

[eluser]kongfjong[/eluser]
Works like a charm, thanks.

But what about all the other stuff from the link? This stuff

Code:
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
    
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]



htaccess help - El Forum - 02-24-2011

[eluser]Jaketoolson[/eluser]
Are you using CI 2.0?

Basically those rules just mean if someone were to manually type into the url (trying to gain access to the CI system/application folders) :

http://www.footballground.dk/application/
or
http://www.footballground.dk/system/

They'd get booted and redirected to the homepage. I don't use these...


htaccess help - El Forum - 02-24-2011

[eluser]kongfjong[/eluser]
Yes I do Smile