3
我有一個.htaccess中爲我的網站如何爲.htaccess編寫多個條件和規則?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ profile.php?membername=$1 [L]
RewriteRule ^poem/(.*)/?$ poem.php?id=$1 [L,NC]
</IfModule>
# Works
RewriteRule ^(.*)$ profile.php?membername=$1 [L]
# Does not work
RewriteRule ^poem/(.*)/?$ poem.php?id=$1 [L,NC]
如果這一切改變這種波紋管,則結果相反。
# No longer works:
RewriteRule ^(.*)$ profile.php?membername=$1 [L]
# Now works:
RewriteRule ^poem/(.*)/?$ poem.php?id=$1 [L,NC]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} -f
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^(.*)$ profile.php?membername=$1 [L]
RewriteRule ^poem/(.*)/?$ poem.php?id=$1 [L,NC]
</IfModule>
發生了什麼事?我不知道。
謝謝!我剛剛發現,如果我將RewriteRule^poem /(.*)/?$ poem.php?id = $ 1 [L,NC]放在條件完美的條件之前。 – Joshua 2013-03-01 01:20:51