Welcome Guest, Not a member yet? Register   Sign In
[solved] Noob Question: removing index.php from URL... fresh CI installation
#1

[eluser]Fenix[/eluser]
Okay, first of all, I'm new to CI... BRAND new. I started going through the user guide and right away things aren't so clear to me >.<

I want to remove the index.php from my URLs. I'm unsure where the .htaccess file goes, if there is already one there on a fresh install, and what exactly should it do. I searched in these forums but could only find solutions in the context of other user's specific needs.

I have a fresh installation of CI so if somebody could tell me exactly where the file goes and what should be in it, that would be great.

Thanks

^__^
#2

[eluser]Fenix[/eluser]
Ok, I missed a bit when I read through the user guide.

So I made a .htaccess file in my site root (same place as my index.php) with the following:
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

I also changed the line in my config to:
Code:
$config['index_page'] = "";

Now I get a 404 Not Found
Quote:Not Found

The requested URL /index.php/ was not found on this server.
#3

[eluser]Xeoncross[/eluser]
Read This thread for more help with your .htaccess file.

I bet that you are having a problem with your:

Code:
# The RewriteBase of the system (if you are using this system in a sub-folder).
RewriteBase /CodeIgniter_1.6.3/
#4

[eluser]Fenix[/eluser]
My CI installation is in a folder under the domain I use for my projects...

Code:
// system folder...
www.mydomain.com/projectname/system/
// codeigniter index.php
www.mydomain.com/projectname/index.php
#5

[eluser]Fenix[/eluser]
i guess this
Code:
RewriteRule ^(.*)$ /index.php/$1 [L]
should have been
Code:
RewriteRule ^(.*)$ index.php$1 [L]

but i dont know if this will cause problems down the line since it isn't adding a slash to the end... idk... i guess i will find out
#6

[eluser]Fenix[/eluser]
Just as I expected I am getting a 404

Code:
The requested URL /si/index.phphelloworld was not found on this server.

helloworld is a controller like in the user guide
Code:
&lt;?php
class HelloWorld extends Controller {
    function index()
    {
        echo 'Hello World';
    }
}

How do I get the slash to show up there?
#7

[eluser]Xeoncross[/eluser]
[quote author="Fenix" date="1218062174"]My CI installation is in a folder under the domain I use for my projects...
[/quote]

So then you would need:
Code:
#RewriteBase /
RewriteBase /projectname/


Lets say your filesystem looks like this: /root/www/mydomain.com/
and your Codeigniter file system path is: /root/www/mydomain.com/projectname/index.php/
Your htaccess file would be:
Code:
RewriteBase /projectname/
so that a url like:
mydomain.com/controller/method
would point to
/root/www/mydomain.com/projectname/index.php/controller/method
#8

[eluser]Fenix[/eluser]
Thanks but the thread you linked to in your first reply turned out to be exactly what I needed to make it work. I didn't have to make any mods to the script from that thread.




Theme © iAndrew 2016 - Forum software by © MyBB