Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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

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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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 REWRITE强制将一个特定页面设置为HTTP(.htaccess)_Apache_.htaccess_Mod Rewrite_Server Side - Fatal编程技术网

使用APACHE REWRITE强制将一个特定页面设置为HTTP(.htaccess)

使用APACHE REWRITE强制将一个特定页面设置为HTTP(.htaccess),apache,.htaccess,mod-rewrite,server-side,Apache,.htaccess,Mod Rewrite,Server Side,我尝试过使用一些重写将我的/welcome.php页面更改为http。它位于根目录中,但我所做的似乎迫使我的站点上的所有页面都使用http,而不仅仅是一个页面。以下是我尝试过的: RewriteEngine On #Force remove WWW RewriteCond %{HTTP_HOST} ^www.w5unt.ga RewriteRule (.*) http://w5unt.ga/$1 [R=301,L] #Redirect HTTPS to HTTP RewriteCond %{

我尝试过使用一些重写将我的/welcome.php页面更改为http。它位于根目录中,但我所做的似乎迫使我的站点上的所有页面都使用http,而不仅仅是一个页面。以下是我尝试过的:

RewriteEngine On

#Force remove WWW
RewriteCond %{HTTP_HOST} ^www.w5unt.ga
RewriteRule (.*) http://w5unt.ga/$1 [R=301,L]

#Redirect HTTPS to HTTP
RewriteCond %{HTTP:X-Forwarded-Proto} =https
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
正如您所看到的,我还强制从所有URL中删除WWW,同时我试图强制我的一页welcome.php为http。我相信错误就在这段代码中 重写规则^.*$http://%{http_HOST}%{REQUEST_URI}[L,R=301]
然而,我不知道如何从语法上纠正我的问题,有什么建议吗

试试下面的内容,我已经编辑了您规则的一部分,并对welcome.php进行了排除检查

RewriteEngine On

#Force remove WWW
RewriteCond %{HTTP_HOST} ^www.w5unt.ga
RewriteCond %{REQUEST_URI} !^/welcome.php
RewriteRule (.*) https://w5unt.ga/$1 [R=301,L]

实际上,^.*$是一个catchall表达式,因此所有页面都降级为http。类似这样的东西应该可以做到:重写规则^welcome\.php$http://w5unt.ga/welcome.php 嘿!谢谢你的建议,我今晚会尝试一下,如果它有效,我会把你的回答标记为正确@Leath出了什么问题,您是否事先清除了缓存。