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 没有协议时重定向到index.php的URL_Apache_.htaccess_Mod Rewrite_Drupal - Fatal编程技术网

Apache 没有协议时重定向到index.php的URL

Apache 没有协议时重定向到index.php的URL,apache,.htaccess,mod-rewrite,drupal,Apache,.htaccess,Mod Rewrite,Drupal,希望有更多htaccess经验的人能帮助我们。我们有Drupal7站点,我们刚刚从一个开发人员转移到了实时主机(不同的主机公司)。但是,现在如果有人将没有协议的url直接放入地址栏(例如:examplesite.com/members),页面将重定向到examplesite.com/index.php。我一直在试图在htaccess文件中解决这个问题,但没有找到允许URL不带协议的正确语法,同时也强制使用https:// 我们的守则: RewriteCond %{REQUEST_FILEN

希望有更多htaccess经验的人能帮助我们。我们有Drupal7站点,我们刚刚从一个开发人员转移到了实时主机(不同的主机公司)。但是,现在如果有人将没有协议的url直接放入地址栏(例如:examplesite.com/members),页面将重定向到examplesite.com/index.php。我一直在试图在htaccess文件中解决这个问题,但没有找到允许URL不带协议的正确语法,同时也强制使用https://

我们的守则:

   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d 
   RewriteCond %{REQUEST_URI} !=/favicon.ico
   RewriteRule ^ index.php [L]


  RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
我们已经尝试将RewriteRule^index.php[L]行移到所有规则的下面,或者将其注释掉。这修复了最初的问题,但破坏了后端的drupal管理功能(无法查看管理菜单,无法保存任何内容,等等)


任何见解都会有帮助,如果需要更多信息,请告诉我。先谢谢你

您需要将整个块、条件+规则移动到底部。Drupal通过
index.php
脚本路由所有内容,它需要前面的3个条件才能正确执行。如果只需移动
RewriteRule
行,则所有条件都将消失

RewriteEngine On

# this needs to come first
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

# then drupal stuff comes LAST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

您是否尝试在重写规则中使用
/$1
而不是
%{REQUEST\u URI}
?(如果您还想保留任何可能的查询字符串,请添加标志QSA。)没有协议的URL是什么意思?当您在浏览器中键入
examplesite.com/members
时,浏览器实际上会发送
http://examplesite.com/members
到web服务器。