0

Hoping someone with more htaccess experience can help us with this. We have Drupal 7 site that we have just moved from a dev to the live host (different hosting companies). However, now when someone puts a url with no protocol directly into the address bar (for example: examplesite.com/members), the page redirects to examplesite.com/index.php. I have been muddling around trying to fix this in the htaccess file, but have not been able to find the proper syntax for allowing urls with no protocol, while also forcing https://.

Our code:

   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]

We have tried moving the RewriteRule ^ index.php [L] line to underneath all rules, or commenting it out. This fixed the initial problem, but breaks the drupal admin functionality on the backend (can't see the admin menu, can't save anything, etc)

Any insight would be helpful, let me know if more info is needed. Thank you in advance.

4

1 回答 1

0

您需要将整个块、条件+规则移动到底部。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]
于 2013-10-17T17:14:35.650 回答