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然後運行下載/ foo.php
如果請求的URL是http://localhost/ {file} /foo/bar.php然後運行文件/ foo/bar.php
如果不是在規則中則運行main/index.php