Merge 2 mod_rewrite conditions in .htaccess

2

About .htaccess and mod_rewrite not understanding anything at all!

The situation is as follows, I have 2 projects in different domains:

  • This first project uses the condition below that always directs the browser to the HTTPS protocol by disabling HTTP browsing.

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    
  • This second project uses the condition below that enables friendly URL-browsing.

    RewriteEngine on
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?url=$1
    
  • The question now is, I need to merge these conditions into a 3rd project, because it has SSL (HTTPS) enabled and also rewrite to friendly URLs.

        
    asked by anonymous 29.10.2015 / 18:02

    1 answer

    2

    I think so, just use a RewriteCond before its RewriteRule specific and you may also need to use flag [L] :

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
    
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?url=$1
    

    If you have any errors, please let me know.

        
    29.10.2015 / 18:10