Remove index.php BUT keep old links working

Author Message

V. van Velzen

Tuesday 15 September 2009 10:02:14 pm

Good morning,

I'm trying to remove the index.php from the URL, which is working with the .htaccess examples found on this 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 could not find any info on this and was hoping someone could help?
TIA,

Vivienne

Greg McAvoy-Jensen

Tuesday 15 September 2009 10:11:33 pm

Vivienne,

Try adding a rewrite rule to your virtual host file.

Granite Horizon, Certified Developer of eZ Publish Web Solutions
Provider of the SaaS Solution Granite Horizon In The Cloud | http://granitehorizon.com/cloud
http://granitehorizon.com | +1 916 647 6350 | California USA | @granitegreg
Blog: http://granitehorizon.com/blog

V. van Velzen

Tuesday 15 September 2009 10:52:12 pm

Hi Greg,

I tried adding a rewrite rule in the .htaccess file, but apparently am not very proficient with the way .htaccess works as I could not get this to work. What I tried:

RewriteCond ^index.php(.*)$
RewriteRule ^index.php(.*)$ $1 [L]
RewriteRule .* index.php [L]

The third line was already present to make the virtual host setup work.
Any help would be appreciated.

Vivienne

V. van Velzen

Wednesday 16 September 2009 10:27:30 pm

Good morning,

I'm still thinking this should be possible, but that there is an error in my .htaccess syntax (see previous post). Has anyone else run into this problem and was able to fix it using .htaccess? I'd appreciate any help.
TIA,

Vivienne

Peter Keung

Friday 18 September 2009 12:03:10 am

Try being explicit with the domain in the rewrite rule:

RewriteRule ^/index\.php(.*)$ http://www.yoursite.com$1 [R=301, L]

http://www.mugo.ca
Mugo Web, eZ Partner in Vancouver, Canada

V. van Velzen

Monday 21 September 2009 6:46:14 am

Hi Peter,

Thank you for the suggestion, but it (sadly) does not work. These are the lines I have in my .htaccess file:

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

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

This causes the browser to show an error message (which is logical in my eyes, as it creates an infinite loop), but I can't see another way to achieve my goal.
Hasn't anyone switched from using index.php to not using it, and found a working solution to make sure the old index.php links are still working?
TIA,

Vivienne

V. van Velzen

Wednesday 23 September 2009 9:29:22 pm

Hi all,

Sorry for bumping this message, but it's pretty important to get this to work. Does anyone have a solution to the problem of removing the index.php from the address, but keeping the old addresses with index.php working? Pretty important from a SEO perspective...
TIA,

Vivienne

Gaetano Giunta

Thursday 24 September 2009 1:08:31 am

Rewrite rules are the way to go - you just have to find out the correct set...

Principal Consultant International Business
Member of the Community Project Board

V. van Velzen

Thursday 24 September 2009 1:41:58 am

Yes, but that seems to be the problem in my case. As you can see in a previous post, I get an infinite loop trying it my way. So any help would be appreciated.

Vivienne

Neo Pixel

Thursday 01 October 2009 5:11:34 am

Are you sure you added

[SiteAccessSettings]
ForceVirtualHost=true

to the correct site.ini.append.php?

Mine are usually in settings/siteaccess/eng/site.ini.append.php ???

Asking stupid questions so you don't have to!

V. van Velzen

Monday 05 October 2009 12:00:10 am

Hi Neo,

Yes, I've added the ForceVirtualHost to the correct site.ini.append.php file. I don't have any problems removing the index.php from the address, I just can't do it in such a way that old links using index.php still work (i.e. links from Google search results). Any help would still be appreciated, as I've yet to find a solution.
TIA,

Vivienne

Neo Pixel

Monday 05 October 2009 5:30:00 am

Hi Vivienne,

I wouldn't worry too much about retaining the google results. If you resubmit the site to google to indictae a fundamental change then the spiders will soon be round to find everything again.

:-)

Asking stupid questions so you don't have to!

V. van Velzen

Tuesday 06 October 2009 2:31:03 am

True, but not only Google has links to the 'old' index.php pages. The site itself also contains those links (complete links added through the EZPublish CMS), as do other 'friendly' sites. And even though we would go through our site to repair those links, in my opinion it's a better practice to just keep those links working...

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 30 2025 21:35:41
Script start
Timing: Jan 30 2025 21:35:41
Module start 'layout'
Timing: Jan 30 2025 21:35:41
Module start 'content'
Timing: Jan 30 2025 21:35:42
Module end 'content'
Timing: Jan 30 2025 21:35:42
Script end

Main resources:

Total runtime0.0272 sec
Peak memory usage8,192.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 588.3828151.2422
Module start 'layout' 0.00540.0044 739.6250220.7500
Module start 'content' 0.00980.0157 960.37501,013.8672
Module end 'content' 0.02560.0016 1,974.242245.9922
Script end 0.0272  2,020.2344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003211.7858140.0002
Check MTime0.00145.0890140.0001
Mysql Total
Database connection0.00072.552010.0007
Mysqli_queries0.003011.034530.0010
Looping result0.00000.058710.0000
Template Total0.00114.110.0011
Template load0.00083.022710.0008
Template processing0.00031.059010.0003
Override
Cache load0.00062.139910.0006
General
dbfile0.00134.688480.0002
String conversion0.00000.037740.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