htaccess if else index或admin

时间:2013-10-24 04:59:36

标签: php .htaccess if-statement

我有以下htaccess。

是否可以在htaccess中执行if / elseif。示例: 如果http://url.nl/rs/ elseif http://url.nl/rs/admin/

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . rs/index.php [L]
RewriteRule . rs/admin/index.php [L]

1 个答案:

答案 0 :(得分:2)

是的,有可能:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^url\.nl/rs$ [NC]
RewriteRule . rs/index.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^url\.nl/rs/admin$ [NC]
RewriteRule . rs/admin/index.php [L]