How Can I Have A Conditional .htaccess Block?

前端 未结 4 1998
说谎
说谎 2020-12-05 05:47

This is an Apache question you\'ve probably come across before. I want to have one source package that I can deploy to my workstation, my staging server, and my production s

4条回答
  •  盖世英雄少女心
    2020-12-05 06:03

    Here is a simple example that should be enough for you to change it to meet your requirements:

    
        RewriteEngine On
    
        RewriteBase /
    
        RewriteCond %{HTTP_HOST} !^localhost
        RewriteCond %{HTTP_HOST} !^www\.
        RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
    
    

提交回复
热议问题