I'm trying to redirect all https traffic to http except for a url. I wrote the redirection rule but I don't understand why for this url I want to exclude I'm redirected to index.php. For all the others the redirection is ok.

The .htaccess file is the one that comes by default with Drupal 7. Before the redirection to index.php I added the following rewriting rule (the first 3 lines of code):

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/custom-url
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

So with the above rules I have:

https:// drupal.local/custom-url redirects to http:// drupal.local/index.php

https:// drupal.local/any/other-url redirects to http:// drupal.local/any/other-url

And I want that:

https:// drupal.local/custom-url to not redirect to anything and to remain like it is, on https.

Any help is appreciated.

  • The short, incomplete, answer is that the next rewrite rule block continues to process the URL you excepted in the first one. But, you probably already know that. – cilefen Oct 31 '15 at 21:35
  • Yes, I know that it will go to the second rewrite rule. But even when I comment the first 3 lines of code it will go directly to the 'index.php' rule and it will stay on https with the same uri but it will not redirect to index.php. So even if the first rule doesn't apply it still somehow affects the outcome. – lhangea Oct 31 '15 at 21:48
  • The meaning of these lines: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ...is "ignore this rule if there is a real file or directory being accessed. – cilefen Nov 2 '15 at 0:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.