Welcome Guest, Not a member yet? Register   Sign In
Having issues removing that index.php. Tried all possible solutions with no luck :(
#1

[eluser]Unknown[/eluser]
Hello Forum,

Can someone please help? I've been at this for hours with no luck and would really appreciate some help.

First off I am using MAMP Pro with SSL test env. So CI is running on https://

Here is my config URL snippet

Code:
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = 'https://mysite/';

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';

Here is what my .htaccess looks like.

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|css|js|fonts|img)
RewriteRule ^(.*)$ /index.php/$1 [L]


Here is what my current load test looks like.
https://mysite/ <-- Home Controller loads.
https://mysite/index.php/home <-- Home controller loads.
https://mysite/home <-- FAIL. Home page does not load.

Could someone help me with this please? I'm not sure how to proceed with this issue.

Thank you for reading.
#2

[eluser]ahmad saad[/eluser]
Hi,
try this in ur .htaccess file and let me know.
Code:
<IfModule mod_rewrite.c>
        RewriteEngine On
  
        RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]        
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

Regard's
#3

[eluser]Unknown[/eluser]
[quote author="ahmad saad" date="1394412463"]Hi,
try this in ur .htaccess file and let me know.
Code:
<IfModule mod_rewrite.c>
        RewriteEngine On
  
        RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]        
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

Regard's[/quote]

Hi ahmad saad, doesn't work Sad

Code:
Not Found

The requested URL /home was not found on this server.


Can someone verify if I have the .htaccess in the right structure?

site
-|system
-|application
-|-|.htaccess

the .htaccess file resides in the application folder within the application folder. So the path is site/application/.htaccess..is this correct?

Thank you again for all the help.
#4

[eluser]ahmad saad[/eluser]
Hi,

as I think u must but it in the root doucment ,

and if u install it in subfolder u must put the .htaccess in this subfolder and remove "/" before index.php so it will be:
Code:
RewriteRule ^(.*)$ index.php/$1 [L]

Regard's.
#5

[eluser]InsiteFX[/eluser]
This is the one I use from FuelPHP, works for me everytime.

Code:
<IfModule mod_rewrite.c>

# pass the default character set
AddDefaultCharset utf-8

    # Make sure directory listing is disabled
Options +FollowSymLinks -Indexes

RewriteEngine on

# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
RewriteBase /

# Restrict your site to only one domain
# !important USE ONLY ONE OPTION

# Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines.
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines.
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#RewriteCond %{HTTP_HOST} (.+)$ [NC]
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

# Remove index.php from URL
RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$
RewriteCond %{THE_REQUEST}    ^[^/]*/index\.php [NC]
RewriteRule ^index\.php(.*)$   $1 [R=301,NS,L]

# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# deal with php5-cgi first
<IfModule mod_fcgid.c>
  RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>

<IfModule !mod_fcgid.c>

  # for normal Apache installations
  <IfModule mod_php5.c>
   RewriteRule ^(.*)$ index.php/$1 [QSA,L]
  </IfModule>

  # for Apache FGCI installations
  <IfModule !mod_php5.c>
   RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
  </IfModule>

</IfModule>

</IfModule>
#6

[eluser]micfai[/eluser]
In the virtualhost you have to allow overrides for the directory. By default its usually AllowOverride None. Change that to AllowOverrider All
#7

[eluser]InsiteFX[/eluser]
If you look at my .htaccess file AllowOveride All is there its just remarked out.
#8

[eluser]1cookie[/eluser]
Here's a simple one that works for me:

Code:
# Allows us to remove index.php from the URL
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Do you have root access to you're server? I would also look at you're server configuration:

Code:
<Directory /var/www/public_html />
     AllowOverride All
</Directory>

I thought CodeIgniter worked this out for itself:

Code:
# /application/config/config.php
$config['index_page'] = '';
#9

[eluser]hobartimus[/eluser]
I use the version provided in the EE docs on my production server and it works fine, but it does not work on my local MAMP server. Your shortened version works fine on my local MAMP server. Any idea why that would be?
#10

[eluser]Tim Brownlaw[/eluser]
I was just checking the mod_rewrite settings on MAMP... It appears that it is enabled by default (from what I've read ). Usually in a new install like WAMP or LAMP you need to enable it as it's off by default.


Your htaccess file has to be in your document root.. The same folder as your index.php above your application folder and it's friends!


Also check in your /Applications/MAMP/conf/apache/httpd.conf that you have

<Directory <path>>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>

Where <path> is the folder path above your websites.. For instance , if you have your sites as /home/<sitename>/public_html you would set <path> to be /home/

That way those settings will apply to all the folders above /home/... So make sure you have that correct and when you make any changes to your servers settings - Make Sure you always restart the server!

Cheers
Tim




Theme © iAndrew 2016 - Forum software by © MyBB