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/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/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
Apache 要求htaccess从https重定向*_Apache_.htaccess_Redirect - Fatal编程技术网

Apache 要求htaccess从https重定向*

Apache 要求htaccess从https重定向*,apache,.htaccess,redirect,Apache,.htaccess,Redirect,我有一个htaccess,允许用户使用https并实现一些语义url。 这是: Options -MultiViews RewriteEngine On RewriteCond %{HTTPS} off [NC] RewriteRule ^https://%{HTTP_HOST}%{REQUEST_URI} [R,L] RewriteRule ^(index|getReadings|admin|adminNewDesign)\/([A-Za-z]*)$ https://%{HTTP_HOST}

我有一个htaccess,允许用户使用https并实现一些语义url。 这是:

Options -MultiViews
RewriteEngine On

RewriteCond %{HTTPS} off [NC]
RewriteRule ^https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteRule ^(index|getReadings|admin|adminNewDesign)\/([A-Za-z]*)$ https://%{HTTP_HOST}/$1.php?id=$2 [L,QSA,NC]
RewriteRule ^adminNewDesign$ https://%{HTTP_HOST}/adminNewDesign/addingOperators/i [L,QSA,NC]
RewriteRule ^admin$ https://%{HTTP_HOST}/admin.php [L,QSA,NC]
RewriteRule ^(index)/(reg)/(byphone|byemail)?$ https://%{HTTP_HOST}/$1.php?id=$2&loginform=$3 [L,QSA,NC]
RewriteRule ^(index|getReadings|admin|adminNewDesign)/(\w+)/(\d+)/?$ https://%{HTTP_HOST}/$1.php?id=$2&page=$3 [L,QSA,NC]
RewriteRule ^(index|getReadings)/(fullpage)/(true)/?$ https://%{HTTP_HOST}/$1/php?$2=$3 [L,QSA,NC]
RewriteRule ^(admin|adminNewDesign)\/([A-Za-z]*)/([A-Za-z]*)$ https://%{HTTP_HOST}/$1.php?id=$2&device=$3 [L,QSA,NC]
RewriteRule ^adminNewDesign\/(individualAnalogueNotification|analogueNotification|intercomNotification)/record-([0-9]+)\.wav$ https://%{HTTP_HOST}/play_audio.php?recordType=$1&record_id=$2 [L,QSA,NC]
它工作正常,例如从索引/测试重定向到。 但当我转到adminNewDesign时,它会重定向到

当我使用http时,另一个规则在这里工作,这一个:

RewriteRule ^(admin|adminNewDesign)\/([A-Za-z]*)/([A-Za-z]*)$ https://%{HTTP_HOST}/$1.php?id=$2&device=$3 [L,QSA,NC]
但最后一个重定向现在不起作用,它给出了404错误。 所以看起来像是
^(admin | adminNewDesign)\/([A-Za-z]*)/([A-Za-z]*)$
适合但不适合。
那么,如何显示htaccess以从类似https的url重定向?

对于
https=>http
,您只需要在顶部重定向一次,其余的应该是内部重写,如下所示:

Options -MultiViews
RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,NE,L]

RewriteRule ^(index|getReadings|admin|adminNewDesign)/([A-Za-z]*)/?$ $1.php?id=$2 [L,QSA,NC]

RewriteRule ^adminNewDesign/?$ adminNewDesign/addingOperators/i [L,QSA,NC]

RewriteRule ^admin/?$ admin.php [L,QSA,NC]

RewriteRule ^(index)/(reg)/(byphone|byemail)?/?$ $1.php?id=$2&loginform=$3 [L,QSA,NC]

RewriteRule ^(index|getReadings|admin|adminNewDesign)/(\w+)/(\d+)/?$ $1.php?id=$2&page=$3 [L,QSA,NC]

RewriteRule ^(index|getReadings)/(fullpage)/(true)/?$ $1/php?$2=$3 [L,QSA,NC]

RewriteRule ^(admin|adminNewDesign)/([A-Za-z]*)/([A-Za-z]*)/÷$ $1.php?id=$2&device=$3 [L,QSA,NC]

RewriteRule ^adminNewDesign\/(individualAnalogueNotification|analogueNotification|intercomNotification)/record-([0-9]+)\.wav$ play_audio.php?recordType=$1&record_id=$2 [L,QSA,NC]

清除浏览器缓存后进行测试。

奇怪,但这根本不起作用。给我看404。我清除了chrome的缓存并以匿名模式打开它。另外,我上一个问题中的人建议将https://%{HTTP_HOST}/添加到重定向中。它工作得更好。
getReadings.php
在哪里?什么是
https
站点的
DocumentRoot