htaccess (removing index.php) and online editor

Author Message

Tim Dickinson

Sunday 25 June 2006 5:03:43 am

Hi all,

Thanks to the eZ team for releasing the Online Editor under GPL.

I have a problem though. I have a few rewrite rules in my .htacces to remove index.php from my site urls which works excellently.

Here's my .htaccess:

<edit>DO NOT USE THIS CODE - use the code a few posts down - that one actually works ;-)</edit>

php_value magic_quotes_gpc 0
php_value register_globals 0

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>

RewriteEngine on

# we are reached via // prefix
RewriteBase /index.php/1/
# first we rewrite the root dir to the handling php script
RewriteRule ^$ index.php [L]
RewriteRule ^index\.html$ index.php [L]

# strip out the subdirs when the browser requests us from per dir pages
RewriteRule ^.+/+/.$ $1 [L]

# and now break the rewriting for local files
RewriteRule ^/index.php/1/\.php.* - [L]
RewriteRule ^settings\.* - [L]
RewriteRule ^design\.* - [L]
RewriteRule ^var\.* - [L]
RewriteRule ^share\.* - [L]
RewriteRule ^images\.* - [L]
RewriteRule ^extension\.* - [L]

# anything else is a subdir which gets handled by another php script
RewriteRule !^index\.php.* - [C]
RewriteRule (.*) index.php/$1

My problem is, however, that I can't get the OE to work. It doesn't show up at all when using the rewrite rules. It did work fine when I wasn't using the rules so I know it works fine and there is something in the rules above that is stopping it working.

I've tried adding the following to my .htaccess

RewriteRule !\.(gif|css|jpg|png|jar|js)$ /index.php

If I add it to the top of my htaccess (under rewrite rule on) - I get a 400 Error on the whole site so doesn't work. If I add it to the bottom I get a 500 error on the whole site.

Anyone got any ideas where I'm going wrong?

Thanks in advance,

Tim

http://www.AdBalance.com - Ad network news and reviews
http://www.DevPublisher.com - Website publisher guides, tools and news
http://www.AudioMelody.com - Make better music

Vjeran Vlahovic

Sunday 25 June 2006 5:33:39 am

Hi Tim,
here is my .htacces config, hope this will help you:

php_value allow_call_time_pass_reference 0
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value memory_limit "384M"
php_value max_execution_time 400
php_value max_input_time 400

Options +FollowSymlinks

RewriteEngine On

RewriteRule ^var/storage/.* - [L]
RewriteRule ^var/[^/]+/storage/.* - [L]
RewriteRule ^var/cache/texttoimage/.* - [L]
RewriteRule ^var/[^/]+/cache/texttoimage/.* - [L]
RewriteRule ^design/[^/]+/(stylesheets|images|imagespl|javascript)/.* - [L]
RewriteRule ^share/icons/.* - [L]
RewriteRule ^sitemaps/.* - [L]
RewriteRule ^extension/[^/]+/design/[^/]+/(stylesheets|images|javascripts?)/.* - [L]
RewriteRule ^extension/tracewatch/.* - [L]
RewriteRule ^packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
RewriteCond $1 !^index.php$
RewriteRule (.*) /index.php

DirectoryIndex index.php

http://www.netgen.hr/eng

Tim Dickinson

Sunday 25 June 2006 6:40:11 am

Thanks for that Vjeran,

Have you got the Online Editor Working?
Your method works great for removing the index.php from the urls (the method I posted works too but yours looks abit neater :-))

The OE still doesn't show up for me.

Any other ideas?

Tim

http://www.AdBalance.com - Ad network news and reviews
http://www.DevPublisher.com - Website publisher guides, tools and news
http://www.AudioMelody.com - Make better music

Tim Dickinson

Monday 26 June 2006 10:57:03 am

In case anyone else is having similar problems, here is my htaccess that works :)

DirectoryIndex index.php

RewriteEngine On

RewriteRule !\.(gif|jpe?g|png|css|js|jar|html)|var(.+)storage.pdf(.+)\.pdf?$ - [C]

RewriteCond %{HTTP_HOST} ^webdav\..*
RewriteRule ^(.*) webdav.php [L]
RewriteCond %{HTTP_HOST} ^soap\..*
RewriteRule ^(.*) soap.php [L]
RewriteRule ^var/cache/debug.html.* - [L]
RewriteRule ^var/[^/]+/cache/debug.html.* - [L]
Rewriterule ^var/storage/.* - [L]
Rewriterule ^var/[^/]+/storage/.* - [L]
RewriteRule ^var/cache/texttoimage/.* - [L]
RewriteRule ^var/[^/]+/cache/texttoimage/.* - [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 .* index.php [L]

Cheers

Tim

http://www.AdBalance.com - Ad network news and reviews
http://www.DevPublisher.com - Website publisher guides, tools and news
http://www.AudioMelody.com - Make better music

Sergiy Korobkov

Wednesday 12 July 2006 1:49:17 pm

Hi Tim,

Thanks for the .htaccess, works great. But how do you actually remove "/index.php/" from the URL's generated by eZ publish?

Thank you.

Serge

Vjeran Vlahovic

Wednesday 12 July 2006 5:02:02 pm

Hi Sergiy,

You have to add one directive inside settings/override/site.ini.append.php:

ForceVirtualHost=true

inside [SiteAccessSettings] section.

Don't forget to clear all caches after that.

http://www.netgen.hr/eng

Sergiy Korobkov

Thursday 13 July 2006 10:57:44 am

Thanks, Vjeran!

Dmytro Korobkov

Friday 14 July 2006 12:41:22 pm

Hi Tim,

I'm using your .htaccess file and it seems that there is small mistake somewhere...

My css files does not work:

@import url("/design/corporate_site/override/stylesheets/core.css");

@import url("/design/corporate_site/override/stylesheets/site.css");

Can you help?

Jochem Duin

Tuesday 01 August 2006 10:14:16 am

This looks really good.

I tried to fix this index.php/ thing but without any luck. I am using ezpublish-3.5.11-gpl without OE.
my installation is in a subdir (/information) of my root and the domain is pointing to that subdir

my setting/override/site.ini.append.php contains

[Session]
SessionNameHandler=custom

[SiteSettings]
DefaultAccess=news
SiteList[]
SiteList[]=news

[SiteAccessSettings]
ForceVirtualHost=true
CheckValidity=false
AvailableSiteAccessList[]
AvailableSiteAccessList[]=news
AvailableSiteAccessList[]=news_admin
MatchOrder=uri
HostMatchMapItems[]

[MailSettings]
Transport=sendmail
AdminEmail=*******
EmailSender=
*/ ?>

and the .htacces files contains

php_value magic_quotes_gpc 0
php_value register_globals 0
<Limit GET POST> order deny,allow
deny from all
allow from all
</Limit> 
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
RewriteEngine on 
# we are reached via // prefix RewriteBase /index.php/1/ 
# first we rewrite the root dir to the handling php script


RewriteRule ^$ index.php [L]
RewriteRule ^index\.html$ index.php [L] 
# strip out the subdirs when the browser requests us from per dir pages
RewriteRule ^.+/+/.$ $1 [L]
# and now break the rewriting for local files
RewriteRule ^/index.php/1/\.php.* - [L]
RewriteRule ^settings\.* - [L]
RewriteRule ^design\.* - [L]
RewriteRule ^var\.* - [L]
RewriteRule ^share\.* - [L]
RewriteRule ^images\.* - [L]
RewriteRule ^extension\.* - [L]
# anything else is a subdir which gets handled by another php script
RewriteRule !^index\.php.* - [C]
RewriteRule (.*) index.php/$1

any1 knows thats wrong?

Tim Dickinson

Tuesday 01 August 2006 11:04:29 am

Missed this thread - sorry about the late replies.

I'm no htaccess expert I'm afraid, I just customised examples of other peoples' .htaccess files to suite my needs.

Dmytro - can you access your css files directly, ie type in the url and access them on their own? I couldn't find what the problem was.

Jochem - Could you post what's in your settings/siteaccess/YOUR_ACCESS/site.ini.append.php

- Also, at the moment your htaccess is set up to work with you using a siteaccess and design both called "1" (as it is on my site). Have you tried the second htaccess example? That worked a lot better for me.

Tim

http://www.AdBalance.com - Ad network news and reviews
http://www.DevPublisher.com - Website publisher guides, tools and news
http://www.AudioMelody.com - Make better music

Jochem Duin

Tuesday 01 August 2006 11:17:56 pm

Tim:
Its working, i used the second method and the stylesheet is also working (not with the first one)

DirectoryIndex index.php
RewriteEngine On
RewriteRule !\.(gif|jpe?g|png|css|js|jar|html)|var(.+)storage.pdf(.+)\.pdf?$ - [C]
RewriteCond %{HTTP_HOST} ^webdav\..*
RewriteRule ^(.*) webdav.php [L]
RewriteCond %{HTTP_HOST} ^soap\..*
RewriteRule ^(.*) soap.php [L]
RewriteRule ^var/cache/debug.html.* - [L]
RewriteRule ^var/[^/]+/cache/debug.html.* - [L]
Rewriterule ^var/storage/.* - [L]
Rewriterule ^var/[^/]+/storage/.* - [L]
RewriteRule ^var/cache/texttoimage/.* - [L]
RewriteRule ^var/[^/]+/cache/texttoimage/.* - [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 .* index.php [L]

my settings/siteaccess/news/site.ini.append.php looks like the following after adding ForceVirtualHost=true.

<?php /* #?ini charset="iso-8859-1"?

[DatabaseSettings]
DatabaseImplementation=ezmysql
Server=********
User=*******
Password=***********
Database=*************
Charset=
Socket=disabled

[InformationCollectionSettings]
EmailReceiver=

[SiteSettings]
SiteName=X-Qlusive Articles
SiteURL=x-qlusive.eu/information/index.php
LoginPage=embedded

[UserSettings]
RegistrationEmail=

[SiteAccessSettings]
ForceVirtualHost=true
RequireUserLogin=false
ShowHiddenNodes=false

[DesignSettings]
SiteDesign=news
AdditionalSiteDesignList[]=base

[RegionalSettings]
Locale=eng-US
ContentObjectLocale=eng-US
TextTranslation=enabled

[FileSettings]
VarDir=var/news

[ContentSettings]
TranslationList=

[MailSettings]
AdminEmail=**********
EmailSender=
*/ ?>

Do you know how to remove /news?
http://www.x-qlusive.eu/news/

Dmytro Korobkov

Friday 04 August 2006 2:05:13 pm

Hi, Tim!

No, I can't access to the css file...

But now I see the problem...

I can access to the /design/base/stylesheets/site.css

And I can't to the /design/corporate_site/override/stylesheets/site.css

Thanks

Rodrigo Paulín

Thursday 10 August 2006 1:22:16 pm

Hi,

I follow the instructions in Jochem's post and it works. index.php is gone!

Now i can't access my admin site.

Hope someone can help me. Thanks.

Rod

Quoi de neuf?

Laurent Patenotre

Monday 14 May 2007 7:07:19 am

This is just my contribution to this topic

I had some problem with the rewrite rules and Online Editor with the new Ez Publish 3.9.2 with ezwebin.

I have changed a little bit your rules and know it's works.

Below you can find my rewrite rules!

Regards

        RewriteRule !\.(gif|jpe?g|png|css|js|jar|html)|var(.+)storage.pdf(.+)\.pdf?$ - [C]
        
        Rewriterule ^/var/.* - [L]
        Rewriterule ^/var/storage/.* - [L]
        Rewriterule ^/var/[^/]+/storage/.* - [L]
        RewriteRule ^/var/cache/texttoimage/.* - [L]
        RewriteRule ^/var/[^/]+/cache/texttoimage/.* - [L]
        Rewriterule ^/design/[^/]+/(stylesheets|images|javascript)/.* - [L]
        Rewriterule ^/share/icons/.* - [L]
        Rewriterule ^/extension/.* - [L]
        Rewriterule ^/extension/[^/]+/design/[^/]+/(stylesheets|images|javascript?)/.* - [L]
        Rewriterule ^/packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
        RewriteRule ^/packages/styles/.+/thumbnail/.* - [L]
        RewriteRule ^/favicon.ico - [L]
        RewriteRule ^/robots.txt - [L]

        RewriteRule .* /index.php [L]

Frédéric DAVID

Tuesday 15 May 2007 8:50:29 am

For Dmytro Korobkov

Add the rewrite rule

Rewriterule ^/design/[^/]+/override/(stylesheets|images|javascript)/.*

The rule allow you to view the css files in the folder override/stylesheets.

Blog : http://www.frefred.fr/blog/ez-publish
feZ Meta Data : http://projects.ez.no/fezmetadata

Brian Baxter

Saturday 30 June 2007 3:56:42 pm

Tim's htaccess code saved my butt, as I was unable to get into the admin site after I set forced virtual host mode=true.

Of course I then went in and cleared the cache. this works like a charm!

Behind every great fortune lies a crime.
http://www.3cwired.com - Web Design/SEO/Repair/Sales/Upgrades
http://www.galants.org - The Home for Galant Enthusiasts
http://www.locatemyip.com - More than just free IP displays

Brian Baxter

Saturday 30 June 2007 4:37:01 pm

Ok I now have a small problem, I am unable to browse into other valid subdirectories under my domain after this htaccess change. is there a way to exclude this on certain directories?

Just to illustrate my point.

Before www.domain.com/web and /apps worked.

now www.domain.com/web takes me to invalid module in ezpublish.

Behind every great fortune lies a crime.
http://www.3cwired.com - Web Design/SEO/Repair/Sales/Upgrades
http://www.galants.org - The Home for Galant Enthusiasts
http://www.locatemyip.com - More than just free IP displays

Brian Baxter

Sunday 01 July 2007 10:10:36 am

Ok after playing around with laurent's code, i was able to display my robots.txt, and other pertinent folders, which were unavailable at the time due to the change I made. basically the bottom of my .htaccess looks like this.

RewriteRule ^robots.txt - [L]
RewriteRule ^samplewebfolder/ - [L]
RewriteRule ^samplewebfile.htm - [L]
RewriteRule .* index.php [L]

when I copied his code directly it didn't work, but now my problems are solved so, hopefully this info helps out others as well.

Behind every great fortune lies a crime.
http://www.3cwired.com - Web Design/SEO/Repair/Sales/Upgrades
http://www.galants.org - The Home for Galant Enthusiasts
http://www.locatemyip.com - More than just free IP displays

Shimon Sandler

Monday 07 July 2008 6:16:10 pm

I also can access the /design/base/stylesheets/site.css

And I can't to the /design/corporate_site/override/stylesheets/site.css

http://no.stron.com

Noicokuna Niemoge

Sunday 01 February 2009 1:42:08 pm

Hello;

I have a problem setuping nice urls... I have this in my htaccess:

<FilesMatch ".">
order allow,deny
deny from all
</FilesMatch>

<FilesMatch "(index\.php|\.(gif|jpe?g|ico|png|pdf|css|js|html)|var(.+)storage.pdf(.+)\.pdf)$">
order allow,deny
allow from all
</FilesMatch>

# If you see "Forbidden" when trying to access root page of your site
# without 'index.php' appended, uncomment the following "Files" section.
# NOTE: replace "ezpublish-3.6.0" with base name of the directory
# where your eZ Publish intallation resides.
# e.g. base name of "/sites/ezpublish/ezpublish-3.6.0" is "ezpublish-3.6.0".

<Files "ezpublish">
   order allow,deny
   allow from all
</Files>

DirectoryIndex index.php

Options +FollowSymlinks
RewriteEngine On

RewriteRule !\.(gif|jpe?g|png|css|js|jar|html)|var(.+)storage.pdf(.+)\.pdf?$ - [C]
RewriteCond %{HTTP_HOST} ^webdav\..*
RewriteRule ^(.*) webdav.php [L]
RewriteCond %{HTTP_HOST} ^soap\..*
RewriteRule ^(.*) soap.php [L]
RewriteRule ^var/cache/debug.html.* - [L]
RewriteRule ^var/[^/]+/cache/debug.html.* - [L]
Rewriterule ^var/storage/.* - [L]
Rewriterule ^var/[^/]+/storage/.* - [L]
RewriteRule ^var/cache/texttoimage/.* - [L]
RewriteRule ^var/[^/]+/cache/texttoimage/.* - [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 .* index.php [L]

My settings are as follows:

MatchOrder= uri; host;
HostMatchType=map
URIMatchMapItems=myhost.com; site
URIMatchMapItems=www.myhost.com; site
CheckValidity=false

Whenever I set ForceVirtualHost=true, I cannot get to admin panel (403 access denied), and on my site there's an error displayed "index.php - module cannot be found".

I cleared all cache wherever possible, still nothing.
I don't have access to apache httpd.conf file (so I didn't setup virtual host), but I've heard it's not required for nice urls.

My eZ runs on php-fcgi.

Please help!

Shiki soku ze ku...

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