Web Analytics Made Easy -
StatCounter RewriteRules in .htaccess (w/ eZ Publish) - CodingForum

Announcement

Collapse
No announcement yet.

RewriteRules in .htaccess (w/ eZ Publish)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RewriteRules in .htaccess (w/ eZ Publish)

    I am attempting to set up a site on a web host using eZ publish 3.8.4. My host is running Apache 1.3.33 with PHP 4.4.2, loaded as an Apache module. I have successfully set up eZ publish on my laptop in the past, but I have hit a roadblock on the host.

    I was following the instructions at http://ez.no/doc/ez_publish/technica...ual_host_setup, but my host does not allow me direct access to httpd.conf, so they set up the virtual host, while I had to use a .htaccess for RewriteRules.

    My .htaccess is as follows:

    Code:
    Options FollowSymLinks
    php_value magic_quotes_gpc 0
    php_value magic_quotes_runtime 0
    php_value allow_call_time_pass_reference 0
    DirectoryIndex index.php
    RewriteEngine On
    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 ^/packages/styles/.+/thumbnail/.* - [L]
    RewriteRule ^/favicon\.ico - [L] RewriteRule ^/robots\.txt - [L]
    RewriteRule ^/var/cache/debug\.html.* - [L]
    RewriteRule ^/var/[^/]+/cache/debug\.html.* - [L]
    RewriteRule .* /index.php
    When I have my .htaccess thus, I receive an http server error 500, and my error_log reads:
    mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.

    If I comment out the last line, then then site works correctly, except with the URL reading:

    instead of:

    I asked my host if the error was due to how the server was configured, and they said:

    Basically, the rewrite rule you are trying to use is impossible because it's an infinite redirect. You need something more concise.
    I looked around the web a little and found an article that described my problem almost exactly: http://www.sitepoint.com/print/mod_r...-endless-loops

    The article suggested changing

    Code:
    RewriteRule .* /index.php
    to:

    Code:
    RewriteRule .* index.php
    This initially appeared to solve the initial problem, by allowing the site to be accessed without 'index.php' in the URL, and without causing an infinite loop or passing an HTTP 500 Server Error.

    This 'solution', however introduced an even more puzzling problem. While the URLs of dynamic content is properly accessible, URLs of static content (i.e. CSS, images, etc.) are erroneously passed to 'index.php' as well, despite being specifically excluded in the RewriteRules.

    I have brushed up (i.e. crammed) on mod_rewrite and regular expressions in general, and have tried various minor variations on the above, but have not been able to find a solution.

    Does anyone have any suggestions as to how I might remedy this problem?

  • #2
    Remove all the /s from after the ^s.

    Or try this:
    Code:
    Options +FollowSymLinks
    DirectoryIndex index.php
    
    php_value magic_quotes_gpc 0
    php_value magic_quotes_runtime 0
    php_value allow_call_time_pass_reference 0
    
    RewriteEngine On
    
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule .+ /index.php

    Comment

    Working...
    X