Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
Apache htaccess将url重写为https并删除文件名_Apache_.htaccess_Symfony_Mod Rewrite_Https - Fatal编程技术网

Apache htaccess将url重写为https并删除文件名

Apache htaccess将url重写为https并删除文件名,apache,.htaccess,symfony,mod-rewrite,https,Apache,.htaccess,Symfony,Mod Rewrite,Https,我正在使用symfony2框架,它为我使用htaccess mod rewrite删除的每个页面调用app.php文件,我正在尝试编写htaccess以将两个页面(带有动态URL)重定向到https,并将站点的其余部分重定向到常规http,这就是我目前的立场: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^(payment|withdraw)(

我正在使用symfony2框架,它为我使用htaccess mod rewrite删除的每个页面调用app.php文件,我正在尝试编写htaccess以将两个页面(带有动态URL)重定向到https,并将站点的其余部分重定向到常规http,这就是我目前的立场:

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteCond %{HTTPS} !=on
    RewriteRule ^(payment|withdraw)(/|$)  https://%{HTTP_HOST}%{REQUEST_URI}  [R=301,L,QSA]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php/$1 [QSA,L]

    #RewriteCond %{HTTPS} =on
    #RewriteRule !^(payment|withdraw)(/|$)  http://%{HTTP_HOST}%{REQUEST_URI}  [R=301,L,QSA]

</IfModule>

重新启动发动机
重写cond%{HTTPS}=在…上
重写规则^(付款|撤回)(/|$)https://%{HTTP|u HOST}%{REQUEST|u URI}[R=301,L,QSA]
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$app.php/$1[QSA,L]
#RewriteCond%{HTTPS}=on
#重写规则^(付款|撤回)(/|$)http://%{http|u HOST}%{REQUEST|u URI}[R=301,L,QSA]
这适用于将https添加到特定页面,但如果我添加注释掉的行以将其余页面重定向到常规http,则会破坏第一部分,而不是第二部分
变成而不是重新排列规则,因为在内部重写规则之前必须保留重定向规则:

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteCond %{HTTPS} off
    RewriteCond %{THE_REQUEST} /(payment|withdraw)[/\s]
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC]

    RewriteCond %{HTTPS} on
    RewriteCond %{THE_REQUEST} !/(payment|withdraw)[/\s]
    RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC]

    RewriteCond %{REQUEST_FILENAME} !-f    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ app.php/$1 [L]

</IfModule>

重新启动发动机
重写条件%{HTTPS}关闭
重写cond%{u请求}/(付款|撤回)[/\s]
重写规则^https://%{HTTP\u HOST}%{REQUEST\u URI}[R=301,L,NC]
在上重写cond%{HTTPS}
重写cond%{THE_REQUEST}/(付款|撤回)[/\s]
重写规则^http://%{http_HOST}%{REQUEST_URI}[R=301,L,NC]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$app.php/$1[L]

谢谢您的评论,但此代码仍然存在相同的问题。请检查其他更新,尽管我相信您的问题是旧的浏览器缓存,而不是规则。