2017-07-03 16 views
0

.htaccessファイル内に複数の規則を書き換える方法はありますか?Apache複数書き換え規則

次は私の.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> 

要求URLがhttp://localhost/ {ダウンロード} /foo.phpある場合は、リクエストURLがhttp://localhost/ある場合は、ダウンロード/ foo.php

を実行します{file} /foo/bar.phpファイル/ foo/bar.phpを実行します

ルールに含まれていない場合、main/index.phpを実行します

答えて

0

ここに例を示します。

<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> 
関連する問題