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?

2
  • I am using the latest version of EE.
    – Amy Witty
    Jan 22, 2013 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? Feb 7, 2013 at 14:28

2 Answers 2

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.

1
  • I did try this, and it didn't work. Thanks for trying to help!
    – Amy Witty
    Feb 8, 2013 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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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