views:

382

answers:

1

Hi all,

I'm trying to remove the index.php from the URL, which is working with the .htaccess examples found on the EZPublish site and ForceVirtualHost=true. The problem is that the old links that point to index.php are no longer working (which is problematic when linking from search engines).

I've tried to find a fix for this in using rewrite rules in .htaccess, but I can't get this to work. Some of my attempts are:

Attempt 1

RewriteCond %{REQUEST_URI} ^/index.php
RewriteRule ^index\.php(.*) http://www.mysite.com$1

RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule .* index.php [L]

This attempt causes an infinite loop.

Attempt 2

RewriteCond %{REQUEST_URI} ^/(index\.php)?(.*)$
RewriteRule %2 index.php [L]

RewriteRule .* index.php [L]

Also doesn't work :-(.

NB. 'RewriteRule .* index.php [L]' is necessary to make the virtual host setup in EZPublish work.

Any help would be greatly appreciated.

Vivienne

A: 

Try to check the request line instead:

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

RewriteRule !^index\.php$ index.php [L]
Gumbo
Hi Gumbo,Thanks for answering, but when I try your suggesting I get an Internal Server Error (which sadly doesn't show up in the errorlog, so I don't have any more information about why the error was thrown).
Vivienne