CodeIgniter Forums
How remove index.php from URL? Works on MAMP, but not Ubuntu. [SOLVED] - 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: How remove index.php from URL? Works on MAMP, but not Ubuntu. [SOLVED] (/showthread.php?tid=34443)



How remove index.php from URL? Works on MAMP, but not Ubuntu. [SOLVED] - El Forum - 09-29-2010

[eluser]CoderReborn[/eluser]
I have it working on my Mac (MAMP), but can't get it working on my Ubuntu (Lucid) hosted server.

This works: mysite.com/index.php/home
But this generates 404 errors: mysite.com/home

I've followed the instructions from this post.

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

- I've confirmed that mod_rewrite is loaded on Apache2.
- The .htaccess file is in the webroot (/var/www), which is also where my index.php and system directory is.
- The .htaccess file permissions are: -rwxrwxr-x

Thanks!


How remove index.php from URL? Works on MAMP, but not Ubuntu. [SOLVED] - El Forum - 09-29-2010

[eluser]Matheus Rocha[/eluser]
Hi,

My .htaccess for this propose is so:

RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|assets|uploads|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Note:
RewriteBase / - after the slash, you must temporarily place the relative path to your base_url:

Exemple:

Your app in the directory in your server is here: public_html/mysite/...
Your RewriteBase will look like: RewriteBase /mysite/

Hope this helps..


How remove index.php from URL? Works on MAMP, but not Ubuntu. [SOLVED] - El Forum - 09-29-2010

[eluser]CoderReborn[/eluser]
@Matheus Rocha - Unfortunately, this is not working for me.


How remove index.php from URL? Works on MAMP, but not Ubuntu. [SOLVED] - El Forum - 09-29-2010

[eluser]Matheus Rocha[/eluser]
Humm..

I work on mac with MAMP too and this working 100%.

You apache has mod_rewrite on?


How remove index.php from URL? Works on MAMP, but not Ubuntu. [SOLVED] - El Forum - 09-29-2010

[eluser]CoderReborn[/eluser]
I have it working on my Mac.

But it's not working on Ubuntu. I've tried about 25 different answers and none of them work.
Yes, I have mod_rewrite on my Ubuntu server.

What other settings need to be setup on Ubuntu?


How remove index.php from URL? Works on MAMP, but not Ubuntu. [SOLVED] - El Forum - 09-30-2010

[eluser]Mark Croxton[/eluser]
Check that you have AllowOverRide All (or another value other than 'None') in the httpd.conf file. Could be Apache is not reading the htaccess file.


How remove index.php from URL? Works on MAMP, but not Ubuntu. [SOLVED] - El Forum - 09-30-2010

[eluser]CoderReborn[/eluser]
Ok, I've got it working now.

Here's what I did:

I found out that in Ubuntu (Lucid) servers, the Apache default virtualhost configuration file) is "/etc/apache2/sites-available/default", not "httpd.conf" (which actually is empty in this O/S distribution).

So, I went to that config file, and made sure that I included the following lines for my webroot directory (/var/www).

Code:
AllowOverride FileInfo
Options FollowSymLink

Then I restarted Apache and it works now.