Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.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文件中的条件重写_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess htaccess文件中的条件重写

.htaccess htaccess文件中的条件重写,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我对.htaccess这个东西还比较陌生,我现在使用下面的方法来使用'pretty url's': <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?path=$1 [NS,L] </IfModule> 但

我对.htaccess这个东西还比较陌生,我现在使用下面的方法来使用'pretty url's':

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?path=$1 [NS,L]
</IfModule>
但我只希望第一个发生在第二个不发生的时候,反之亦然。换句话说,我想要这样的东西:

RewriteRule ^(.*).css$ /csszip.php?file=$1.css [L]
<IfModule mod_rewrite.c>
    RewriteEngine On
    if request doesn't contain .css do
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php?path=$1 [NS,L]
    else do
        RewriteRule ^(.*).css$ /csszip.php?file=$1.css [L]
</IfModule>

重新启动发动机
如果请求不包含.css,请执行
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$index.php?路径=$1[NS,L]
否则会
重写规则^(.*).css$/csszip.php?文件=$1.css[L]
有谁能帮我找到合适的代码或者一个我可以在htaccess文件中使用某种条件语句的地方吗

提前感谢!:)

试试这个

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI} !.css
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?path=$1 [NS,L]

    RewriteRule ^(.*).css$ /csszip.php?file=$1.css [L]
</IfModule>

重新启动发动机
重写条件%{REQUEST_URI}!。css
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$index.php?路径=$1[NS,L]
重写规则^(.*).css$/csszip.php?文件=$1.css[L]

此外,您可以将最后一条规则放在顶部

如果它没有
.css
文件,则自动不使用csszip.php执行一条重写规则后,它会停止执行以下重写规则吗?