7

I use the official EE rewrite rule to remove index.php. This has always worked for me just fine... until now. I am using a hosting company that I've not used before and it is acting funny.

The problem: all routes are getting passed to the main index template, as if there were no additional url segments.

Here is what I'm using:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond $1 !\.(gif|jpe?g|png|pdf|doc|mp3|mov|mp4|tiff|ico|tif)$ [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

Anyone seen this issue before?

Update: I am using an A Small Orange shared plan.

The solution: In config.rb, I needed to change this...

$config['uri_protocol'] = 'AUTO';

to...

$config['uri_protocol'] = 'REQUEST_URI';
  • The $config['uri_protocol'] = 'REQUEST_URI'; works for me. – minhnguyen Apr 10 '14 at 17:27
6

Try adjusting your uri_protocol settings. When I have experienced these issues it has always been solved by specifying "PATH_INFO" or "ORIG_PATH_INFO".

| improve this answer | |
  • Yes, that is it! I actually had to use REQUEST_URI, but that was it. Thanks :) – Matt Fordham Nov 30 '12 at 20:58
  • Glad it worked! – Paulo Elias Nov 30 '12 at 21:16
2

The one I've been using has a nice little comment that might help you:

<IfModule mod_rewrite.c> 
 RewriteEngine On 
 # Removes index.php 
 RewriteCond $1 !\.(gif|jpe?g|png)$ [NC] 
 RewriteCond %{REQUEST_FILENAME} !-f 
 RewriteCond %{REQUEST_FILENAME} !-d 
 RewriteRule ^(.*)$ /index.php/$1 [L] 
 # If 404s, "No Input File" or every URL returns the same thing 
 # make it /index.php?/$1 above (add the question mark)
</IfModule> 
| improve this answer | |
  • 1
    Yeah, tried that... no luck. Also, my issue isn't 404s... it is all routes getting passed to the main index template. In other words the homepage is the only page that'll show. – Matt Fordham Nov 30 '12 at 19:05
  • You might want to mention the name of your hosting company ... someone else hosting there might have the immediate solution for you. – dangerousmeta Nov 30 '12 at 19:29
  • Good idea. Done. – Matt Fordham Nov 30 '12 at 19:32
2

I can't tell you why, but this is what I have. I host several sites with ASO and it has always worked for me. It's also possible there is something in there that isn't needed. I've just hated to mess with something that has worked!

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteRule ^index\.php(.+) $1 [R=301,L]
RewriteCond %{THE_REQUEST} ^GET
</IfModule>
| improve this answer | |
1

The one I use (which always works for me on MediaTemple DV hosting) is slightly different. Maybe it'll work for you:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^/index.php
RewriteCond $1 !.(css|js|png|jpe?g|gif|ico)$ [NC]
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
| improve this answer | |
  • Same issue with that one. grrr :) – Matt Fordham Nov 30 '12 at 19:07
0

You may need to add a ? after index.php

RewriteRule ^(.*)$ /index.php?/$1 [L]
| improve this answer | |
0

I feel dumb for not realizing this before searching, but since this does in fact fix this problem for me: make sure the Apache rewrite module is actually turned on:

a2enmod rewrite

(for Ubuntu)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.