jeudi 19 février 2015

htaccess to nginx rewrite

Hallo,

ich hab da ein kleines Problem .. ich bekomme einfach nicht wirklich hin folgende Datei richtig zu convertieren...




Zitat:








## Uncomment (remove # ONLY NOT ##) line below if installed in folder and add folder name after /

## Example: Script is installed in /public_html/short/ then it should be: Rewritebase /short

## Then the files below should be (add slash to all): /index.php?action=$1

## Uncomment the code below to Use PHP 5.4

# AddHandler application/x-httpd-php54 .php



#Options -MultiViews



RewriteEngine On



## Uncomment the following line to use the multi-domain feature

# RewriteCond %{HTTP_HOST} ^yourseconddomain\.com$ [NC]

# RewriteRule ^(.*)$ http://ift.tt/1EsralK [R=301,L]



#Rewritebase /

## Admin Panel

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^admin/(.*)?$ admin/index.php?a=$1 [QSA,NC,L]



## Sitemap ###

RewriteRule ^sitemap.xml$ sitemap.php



## Application Handler

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)?$ index.php?a=$1 [QSA,NC,L]



## Error 404 ##

ErrorDocument 404 /index.php?a=404



Ich möchte diese Rewrite Rules in ein für NGinx Kompatiblen Format haben... jedoch funktioniert das ganze nicht wirklich .. zu meist möchten die rules die Dateien Downloaden ... @.@



Hier meine 2 Examples:



V1.


Zitat:








if (!-d $request_filename){

set $rule_0 1$rule_0;

}

if (!-f $request_filename){

set $rule_0 2$rule_0;

}

if ($rule_0 = "21"){

rewrite ^/admin/(.*)?$ /admin/index.php?a=$1 last;

}

rewrite ^/sitemap.xml$ /sitemap.php ;

if (!-d $request_filename){

set $rule_2 1$rule_2;

}

if (!-f $request_filename){

set $rule_2 2$rule_2;

}

if ($rule_2 = "21"){

rewrite ^/(.*)?$ /index.php?a=$1 last;

}

error_page 404 /index.php?a=404;



V2.


Zitat:








# nginx configuration

error_page 404 /index.php?a=404;

location / {

if (!-e $request_filename){

rewrite ^/admin/(.*)?$ /admin/index.php?a=$1 break;

}

if (!-e $request_filename){

rewrite ^/(.*)?$ /index.php?a=$1 break;

}

}

location = /sitemap.xml {

rewrite ^(.*)$ /sitemap.php;

}



In beiden Fällen funktioniert das ganze nicht wie gewünscht... Wie gesagt entweder es wird versucht die Datei / Verzeichnis Down zu loaden oder aber wenn ein Formular (zb. Login) angezeigt wird .. fehlen sämtliche CSS / images / Scripte (also auf der Kompletten Seite) usw ...



Das ganze läuft übrigens über ISPConfig3 Management also Sprich die "nginx Directives". Bin mir nicht ganz sicher ob es relevant ist da ISPConfig ja auch ne Vhost mit vorangegangenen Rules erstellt...




Aucun commentaire:

Enregistrer un commentaire