2

I am trying to remove index.php from my URLs on my local WAMP server using the supported .htaccess code:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Removes index.php from ExpressionEngine URLs
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

I went into General Configuration and removed "index.php" from "Name of your site's index page" and saved. I am running EE on a subdirectory (http://localhost:8080/mysite/), so I removed the "/" before "index.php" in the last line:

    RewriteRule ^(.*)$ index.php/$1 [L]

It works for the home page, but for the rest pages when I click the links (which now have the index.php removed), I get this error:

Not Found

The requested URL /mysite/about-us was not found on this server.

I am still able to access the about-us page at /mysite/index.php/about-us.

Can someone please help me?

  • I am using the latest version of EE. – Amy Witty Jan 22 '13 at 22:34
  • Remove the <IfModule mod_rewrite.c> lines, they are a waste of space and only hide potential problems. Try using RewriteRule ^(.*)$ index.php?/$1 [L] instead? – Adrian Macneil Feb 7 '13 at 14:28
1

Make sure AllowOverride All is in the httpd.conf or httpd-vhosts.conf file as per this answer on StackOverflow. You'll need to restart Apache after you make the change.

You may be able to add AllowOverride All at the top of your htaccess file too.

| improve this answer | |
  • I did try this, and it didn't work. Thanks for trying to help! – Amy Witty Feb 8 '13 at 19:52
0

Try with this .htaccess code:

<IfModule mod_rewrite.c>

  # Enable Rewrite Engine
  # ------------------------------
  RewriteEngine On
  RewriteBase /

  # Redirect index.php Requests
  # ------------------------------

RewriteCond %{REQUEST_METHOD} !=POST [NC]
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/system/.*
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]

  # Standard ExpressionEngine Rewrite
  # ------------------------------
  RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{QUERY_STRING} ^(ACT=.*)$ [NC,OR]
 RewriteCond %{QUERY_STRING} ^(URL=.*)$ [NC,OR]
 RewriteCond %{QUERY_STRING} ^(CSS=.*)$ [NC]
 RewriteRule ^(.*)$ /index.php?&%{QUERY_STRING} [L] 
  </IfModule>
| 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.