.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.

eZ debug

Timing: Jan 18 2025 02:50:30
Script start
Timing: Jan 18 2025 02:50:30
Module start 'layout'
Timing: Jan 18 2025 02:50:30
Module start 'content'
Timing: Jan 18 2025 02:50:30
Module end 'content'
Timing: Jan 18 2025 02:50:30
Script end

Main resources:

Total runtime0.0178 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 589.1641152.6406
Module start 'layout' 0.00670.0043 741.804739.4766
Module start 'content' 0.01100.0046 781.281393.9766
Module end 'content' 0.01560.0021 875.257838.3047
Script end 0.0177  913.5625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003117.5082140.0002
Check MTime0.00158.4977140.0001
Mysql Total
Database connection0.00126.745810.0012
Mysqli_queries0.003017.038330.0010
Looping result0.00000.107410.0000
Template Total0.00169.210.0016
Template load0.00095.039510.0009
Template processing0.00074.150810.0007
Override
Cache load0.00063.305110.0006
General
dbfile0.00031.620380.0000
String conversion0.00000.071140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs