With mod_rewrite can I specify a RewriteBase within a RewriteCond?

前端 未结 1 1591
伪装坚强ぢ
伪装坚强ぢ 2020-12-01 03:19

I\'d like to have my .htaccess file specify a different RewriteBase depending on whether the .htaccess file is on my local machine or on a web server. This is the mod_rewri

相关标签:
1条回答
  • 2020-12-01 03:48

    The only solution we finally found looks like that :

    # Activation of the URL Rewriting
    Options +FollowSymlinks
    RewriteEngine On
    
    # RewriteBase equivalent - Production
    RewriteCond %{HTTP_HOST} !^localhost$
    RewriteRule . - [E=REWRITEBASE:/production/path/]
    
    # RewriteBase equivalent - Development
    RewriteCond %{HTTP_HOST} ^localhost$
    RewriteRule . - [E=REWRITEBASE:/development/path/]
    
    # Rewriting
    RewriteRule ^(.*)$ %{ENV:REWRITEBASE}index.php?page=$1 [L]
    

    This code offers a way to simulate differents "RewriteBase".

    0 讨论(0)
提交回复
热议问题