2017-07-03 2 views
0

Wie umschreiben mehrere Regeln in. Htaccess-Datei? Apache mehrere Rewrite-Regel

Das folgende ist meine .htaccess:

<IfModule mod_rewrite.c> 
    RewriteEngine On  

    RewriteCond %{REQUEST_URI} ^/download(.*)$ 
    RewriteRule ^(.*)/download/(.*)$ download/$2 [L] 

    RewriteCond %{REQUEST_URI} ^/file(.*)$ 
    RewriteRule ^(.*)/file/(.*)$ file/$2 [L] 

    RewriteRule ^(.*)$ main/$1 [L] 
</IfModule> 

Wenn Anfrage-URL ist http://localhost/ {Download} /foo.php wird dann laufen download/foo.php

Wenn Anfrage-URL ist http://localhost/ {file} /foo/bar.php dann wird file/foo/bar.php laufen

Wenn nicht in Regeln dann läuft main/index.php

Antwort

0

Hier ist ein Beispiel:

<IfModule mod_rewrite.c> 
    RewriteEngine On  

    RewriteCond %{REQUEST_URI} ^/download/.*$ [NC] 
    RewriteRule ^/download/(.*) download/$1 [L] 

    RewriteCond %{REQUEST_URI} ^/file/.*$ [NC] 
    RewriteRule ^/file/(.*) file/$1 [L] 


    RewriteCond %{REQUEST_URI} !^(/download/(.*)|/file/(.*))$ [NC] 
    RewriteRule ^(.*)$ main/$1 [L] 

</IfModule> 
Verwandte Themen