Imnotapotato
Imnotapotato

Reputation: 5828

CodeIgniter: Removing index.php from the URL

I was trying to remove the index.php from the URL, on my WAMP server THIS worked perfectly, but for some reason on my actual hosted server it's not.

I just created on my current Linux Ubuntu Server a sub-domain, under /var/www/tools.example.com/public_html

I checked if mod_rewrite is enabled using a .php file I uploaded to the dir with this:

<?php 
phpinfo();

and mod_rewrite is under "Loaded Modules". so no worries here.

the .conf file I created in etc/apache2/sites-available/tools.example.com.conf looks like this:

<VirtualHost *:80>
    ServerName tools.example.com
    ServerAdmin [email protected]

    ErrorLog /var/www/tools.example.com/logs/error.log
    CustomLog /var/www/tools.example.com/logs/access.log combined
    DocumentRoot /var/www/tools.example.com/public_html

    <Directory /var/www/tools.example.com.conf/public_html/>
            Options Indexes FollowSymLinks MultiViews
            # changed from None to FileInfo
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

</VirtualHost>

where AllowOverride All so using mod_rewrite with .htaccess is enabled.

I don't know why this is still not working. Any idea why?

the content of the .htaccess file in the main dir:

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

Edit #1:

I already went through all first 9 solutions in this post: CodeIgniter removing index.php from url

Upvotes: 1

Views: 197

Answers (1)

Panama Jack
Panama Jack

Reputation: 24478

Your path is incorrect in your .conf file for the directory directive. Your document root listed should be the same as your Directory directive. So I don't think it's picking up the AllowOverride All directive.

Change this

<Directory /var/www/tools.example.com.conf/public_html/>

To this

<Directory /var/www/tools.example.com/public_html/>

Upvotes: 1

Related Questions