Forums / Install & configuration / .htaccess to remove index.php

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

eZ debug

Timing: Jan 18 2025 00:08:53
Script start
Timing: Jan 18 2025 00:08:53
Module start 'content'
Timing: Jan 18 2025 00:08:54
Module end 'content'
Timing: Jan 18 2025 00:08:54
Script end

Main resources:

Total runtime0.7459 sec
Peak memory usage4,096.0000 KB
Database Queries205

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0089 589.2422180.8281
Module start 'content' 0.00890.6053 770.0703648.5078
Module end 'content' 0.61420.1316 1,418.5781337.0703
Script end 0.7458  1,755.6484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00450.5966210.0002
Check MTime0.00150.1958210.0001
Mysql Total
Database connection0.00190.250710.0019
Mysqli_queries0.659188.37012050.0032
Looping result0.00210.28532030.0000
Template Total0.717996.220.3589
Template load0.00280.381320.0014
Template processing0.715095.854220.3575
Template load and register function0.00010.019810.0001
states
state_id_array0.00040.047210.0004
state_identifier_array0.00100.138620.0005
Override
Cache load0.00230.3119470.0000
Sytem overhead
Fetch class attribute can translate value0.00110.151850.0002
Fetch class attribute name0.00130.178270.0002
XML
Image XML parsing0.00360.476750.0007
class_abstraction
Instantiating content class attribute0.00000.002080.0000
General
dbfile0.00680.9087330.0002
String conversion0.00000.001030.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
6content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 36
 Number of unique templates used: 9

Time used to render debug report: 0.0001 secs