Skip to content

Fix: Rewrite rule#3

Open
lbehm wants to merge 1 commit intoClanCats:masterfrom
lbehm:master
Open

Fix: Rewrite rule#3
lbehm wants to merge 1 commit intoClanCats:masterfrom
lbehm:master

Conversation

@lbehm
Copy link
Copy Markdown
Contributor

@lbehm lbehm commented Aug 24, 2014

You'r welcome ;)

fix behavior some guys simply don't understand
I really don't know why...
lbehm added a commit to lbehm/Core that referenced this pull request Aug 24, 2014
removed hack for really wrong Rewrite Rule
requires ClanCats/Framework#3
@mario-deluna
Copy link
Copy Markdown
Member

This won't work on apache with fastCGI. I have investigated some other applications and came to the following solution:

<IfModule mod_rewrite.c>
    RewriteEngine on

    # If you just receive a 404 error enable and change the rewrite base
    #RewriteBase /path/to/ccf/public

    # Disable directory listing
    Options +FollowSymLinks -Indexes

    # Only Rewrite URL if file not exits
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # Handle different apache environments
    <IfModule mod_fcgid.c>
        RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
    </IfModule>

    <IfModule !mod_fcgid.c>

        # for normal Apache installations
        <IfModule mod_php5.c>
            RewriteRule ^(.*)$ index.php/$1 [L]
        </IfModule>

        # for Apache FGCI installations
        <IfModule !mod_php5.c>
            RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
        </IfModule>

    </IfModule>

</IfModule>

What do you think?

@lbehm
Copy link
Copy Markdown
Contributor Author

lbehm commented Aug 27, 2014

I will test the fastcgi implementation...
But for the mod_php version we just need:

<IfModule mod_php5.c>
  RewriteRule ^(.*)$ index.php [L]
</IfModule>

We strip the entire path and query from the get Param, because apache serve them already to php in the $_SERVER global.

@lbehm
Copy link
Copy Markdown
Contributor Author

lbehm commented Aug 28, 2014

Für FastCGI können wir die selben RewriteRules verwenden.
Ich musste nur beim Start des FastCGI-Servers noch den Parameter -vServer.FixPathInfo=true anhängen.

Aktuell lass ichs bei mir mit der Config laufen:

# If you are using HHVM:
# To set up the HHVM server run
# hhvm --mode server -vServer.Type=fastcgi -vServer.Port=9000 -vServer.FixPathInfo=true
# for help more info follow the instructions at
# https://github.com/facebook/hhvm/wiki/FastCGI
# 
# To prepare Apache2 enable mod_proxy_fcgi, mod_actions, mod_alias
<IfModule mod_fastcgi.c>
    <FilesMatch \.php$>
        SetHandler hhvm-php-extension
    </FilesMatch>

    Alias /hhvm /hhvm
    Action hhvm-php-extension /hhvm virtual

    FastCgiExternalServer /hhvm -host 127.0.0.1:9000 -pass-header Authorization -idle-timeout 300
</IfModule>

# If you arn't using HHVM:
# Just install and enable php5 and mod_rewrite

RewriteEngine On
# If your CCF installation is in a subpath like http://example.com/path/to/ccf
# you must set the following line and update ../CCF/app/config/main.config.php
# RewriteBase /path/to/ccf

# Only Rewrite URL if file not exits
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Default
RewriteRule ^(.*)$ index.php [L]

Das Problem: Alias lässt sich nur im Server oder VirtualHost definieren, weshalb mindestens der IfModule-Block in die Server-Config müsste. Vielleicht lassen wir die .htaccess einfach ganz weg und legen die Beispiele der unterschiedlichen Installationsmöglichkeiten in der Readme.md (oder Wiki?) ab. Es ist ja schon einiges: apache2.2-php, apache2.2-hhvm, apache2.4-hhvm, nginx-php, nginx-hhvm.

Wie machen das eigentlich die ganzen anderen Projekte?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants