Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess Htaccess-主页面的If/esle语句语法_.htaccess - Fatal编程技术网

.htaccess Htaccess-主页面的If/esle语句语法

.htaccess Htaccess-主页面的If/esle语句语法,.htaccess,.htaccess,我想知道检查主页(例如abc.com或localhost)的正确语法,以便为.htaccess文件编写if/else语句。谢谢 <If "abc.com" OR "localhost"> <FilesMatch "\.(css|js|txt)$"> <IfModule mod_expires.c> ExpiresActive Off </IfModule> <If

我想知道检查主页(例如
abc.com
localhost
)的正确语法,以便为
.htaccess
文件编写
if/else
语句。谢谢

<If "abc.com" OR "localhost">
    <FilesMatch "\.(css|js|txt)$">
        <IfModule mod_expires.c>
            ExpiresActive Off
        </IfModule>
        <IfModule mod_headers.c>
            FileETag None
            Header unset ETag
            Header unset Pragma
            Header unset Cache-Control
            Header unset Last-Modified
            Header set Pragma "no-cache"
            Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
            Header set Expires "Mon, 10 Apr 1972 00:00:00 GMT"
        </IfModule>
    </FilesMatch>
</If>
<Else>
    <FilesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
        Header set Cache-Control "max-age=2592000, public"
    </FilesMatch>
</Else>

过期活动关闭
FileTag无
标题未设置ETag
标题未设置Pragma
头取消缓存控制
上次修改未设置的标题
标题集Pragma“无缓存”
标题集缓存控制“最大年龄=0,无缓存,无存储,必须重新验证”
标题集过期“1972年4月10日星期一00:00:00 GMT”
标题集缓存控制“最大年龄=2592000,公共”

你的意思是这样的吗

<ifModule mod_rewrite.c>
    RewriteEngine on
    <If "%{HTTP_HOST} == 'abc.com'">
        RewriteRule ^/?$ /index.php?pages=abc&file=index [NC,L,QSA]
    </If>
    <If "%{HTTP_HOST} == 'localhost'">
        RewriteRule ^/?$ /index.php?pages=localhost&file=index [NC,L,QSA]
    </If>
</ifModule>

重新启动发动机
重写规则^/?$/index.php?pages=abc&file=index[NC,L,QSA]
重写规则^/?$/index.php?pages=localhost&file=index[NC,L,QSA]
这是另一个例子

RewriteEngine On
    # Conditional Settings
    <If "(%{HTTP_HOST} -strmatch '192.168.254.*')">
        # Localhost/XAMPP
        #RewriteBase /XAMPP-Sites/projectX/public_html/

        # No need for a default domain
    </If>
    <Else>
        # Live
        #RewriteBase /

        # Ensure this is the default domain
        #RewriteCond %{HTTP_HOST} .
        #RewriteCond %{HTTP_HOST} !^www\.projectX\.com [NC]
        #RewriteRule (.*) http://www.projectX.com/$1 [R=301,L]
    </Else>
重新编写引擎打开
#条件设置
#Localhost/XAMPP
#重写base/XAMPP站点/projectX/public\u html/
#不需要默认域
#生活
#重写基/
#确保这是默认域
#重写cond%{HTTP_HOST}。
#重写cond%{HTTP_HOST}^www\.projectX\.com[NC]
#重写规则(.*)http://www.projectX.com/$1[R=301,L]