.htaccess to remove index.php

Author Message

laurent le cadet

Thursday 22 April 2010 6:08:03 am

Hi,

I read many thread about .htaccess configuration to remove index.php of url's and tried almost everything but not the right one.

I'm using eZpublish 4.2 with mod_rewrite on server side.
What should I had in .htaccess and should I also set ForceVirtualHost to true in site.ini override?

Thanks for your help.

Laurent

Abdelkader RHOUATI

Friday 23 April 2010 4:46:10 am

Hi,

I confirm, you must put the ForceVirtualHost parameter to true.

I never understood why, for me just add the correct rules of rewriting URL in the file .Htaccess is sufficient.

Can someone explain ? :)

tks

Abdelkader RHOUATI

Blog (french) : http://arhouati.com
----
Extension arh_jdebug : EzDebug using jquery

Norbert Wagner

Friday 23 April 2010 11:41:39 am

Hello,

if you have your mod_rewrite rules correctly in place you should be able to call your pages omitting index.php?/

Since eZ Publish doesn't know anything about it, the generated URL's still contain the index part, that's what the ForceVirtualHost parameter is for, to generate URL's as if you where using the VirtualHost mode.

I came up with the following .htaccess file:

DirectoryIndex index.php

RewriteEngine On

# RewriteCond %{HTTP_HOST} ^webdav\..*
# RewriteRule ^(.*) webdav.php [L]
# RewriteCond %{HTTP_HOST} ^soap\..*
# RewriteRule ^(.*) soap.php [L]
 
RewriteRule content/treemenu/? /index_treemenu.php [L]

RewriteRule ^var/storage/.* - [L]
RewriteRule ^var/[^/]+/storage/.* - [L]
RewriteRule ^var/([^/]+/)?cache/(texttoimage|public)/.* - [L]
             
RewriteRule ^design/[^/]+/(stylesheets|images|javascript)/.* - [L]
RewriteRule ^share/icons/.* - [L]
RewriteRule ^extension/[^/]+/design/[^/]+/(stylesheets|images|javascripts?)/.* - [L]
Rewriterule ^packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
RewriteRule ^packages/styles/.+/thumbnail/.* - [L]
             
RewriteRule ^favicon\.ico - [L]
RewriteRule ^robots\.txt - [L]

# Uncomment the following lines when using popup style debug.
# RewriteRule ^var/cache/debug\.html.* - [L]
# RewriteRule ^var/[^/]+/cache/debug\.html.* - [L]
RewriteRule .* index.php [L]

laurent le cadet

Saturday 24 April 2010 2:53:01 am

Abdelkader, Norbert,

Thanks for your help. Now it's clear and efficient.
In your case Norbert what about this line of the regular .htaccess of eZpublish :

RewriteRule !(\.(gif|jpe?g?|png|css|js|swf|html?)|var(.+)storage.pdf(.+)\.pdf)$ index.php

I don't understand the rewriting rules but what I can read that it's talk about files.
Your configuration seems to ignore them.

Best Regards.

Laurent

PS :

Sao Tavi

Thursday 12 May 2011 12:27:57 pm

This is bad... I was wondering where my acp options have gone. It seems that it was not loading the library files, so, after some research, I found on Virtual-host-setup section in the installation manual that we need to change the line

RewriteRule ^extension/[^/]+/design/[^/]+/(stylesheets|images|javascripts?)/.* - [L]

to

RewriteRule ^/extension/[^/]+/design/[^/]+/(stylesheets|flash|images|lib|javascripts?)/.* - [L]

Sorry for replying in an old thread, but this may lead others, as it lead me, into error.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.