2017-01-17 2 views
1

ich jede Seite über https mit einer Regel bin Laden wie in .htaccesseinige Verzeichnisse ausschließen, während auf https umgeleitet

RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

folgt Ich brauche jede Seite in der Website umleiten über https Protokoll mit Ausnahme einiger Verzeichnisse zu laden. Ich habe versucht, mit dieser Regel

RewriteRule ^dont-load-under-https-folder/ - [L,NC]

Aber es ist noch zu diesen dont-load-under-https-folder

angewandt wird

Hier mein ganzer .htaccess-Code ist

IndexIgnore * 

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 

RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

RewriteCond %{HTTP_HOST} ^52\.76\.80\.144$ 
RewriteRule ^(.*)$ https://mywebsite.com/$1 [L,R=301] 

RewriteRule ^http://52.76.80.144//(.*)$ /$1 [R=301,NC,L] 

## don't touch /forum URIs 
RewriteRule ^forums/ - [L,NC] 
RewriteRule ^detector/ - [L,NC] 

RewriteRule ^admin/ - [L,NC] 
RewriteRule ^b2b/ - [L,NC] 
RewriteRule ^blog/ - [L,NC] 
RewriteRule ^config/ - [L,NC] 
RewriteRule ^hub/ - [L,NC] 

# To remove www header 
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] 
RewriteRule^http://%1%{REQUEST_URI} [L,R=301,NE] 

RewriteCond %{THE_REQUEST} /(\w+)\.php\?param=([^\s&]+) [NC] 
RewriteRule^%1/%2? [R=301,L,NE] 


## hide .php extension snippet 

# To externally redirect /dir/foo.php to /dir/foo 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] 
RewriteRule^%1 [R=301,NE,L] 

# handle ?param=... 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f 
RewriteRule ^(.+)/([\w-]+)/?$ $1.php?param=$2 [L,QSA] 



# To internally forward /dir/foo to /dir/foo.php 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.*?)/?$ $1.php [L] 
RewriteRule ^ending/thankyou(.*?)/?$ $1.php [L] 

RewriteCond %{THE_REQUEST} /main\.html[\s?] [NC] 
RewriteRule ^main\.html$/[L,R=301,NC] 

RewriteRule ^/?$ main.html [L] 


# compress text, html, javascript, css, xml: 
AddOutputFilterByType DEFLATE text/plain 
AddOutputFilterByType DEFLATE text/html 
AddOutputFilterByType DEFLATE text/xml 
AddOutputFilterByType DEFLATE text/css 
AddOutputFilterByType DEFLATE application/xml 
AddOutputFilterByType DEFLATE application/xhtml+xml 
AddOutputFilterByType DEFLATE application/rss+xml 
AddOutputFilterByType DEFLATE application/javascript 
AddOutputFilterByType DEFLATE application/x-javascript 

# Or, compress certain file types by extension: 
<files *.html> 
SetOutputFilter DEFLATE 
</files> 

AddOutputFilterByType DEFLATE text/plain 
AddOutputFilterByType DEFLATE text/html 
AddOutputFilterByType DEFLATE text/xml 
AddOutputFilterByType DEFLATE text/css 
AddOutputFilterByType DEFLATE application/xml 
AddOutputFilterByType DEFLATE application/xhtml+xml 
AddOutputFilterByType DEFLATE application/rss+xml 
AddOutputFilterByType DEFLATE application/javascript 
AddOutputFilterByType DEFLATE application/x-javascript 

AddOutputFilterByType DEFLATE application/vnd.ms-fontobject 
AddOutputFilterByType DEFLATE font/ttf 
AddOutputFilterByType DEFLATE font/otf 
AddOutputFilterByType DEFLATE image/svg+xml 
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject 
<IfModule mod_deflate.c> 
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript 
</IfModule> 


<IfModule mod_headers.c> 
    # WEEK 
    <FilesMatch "\.(jpg|jpeg|png|gif|swf)$"> 
     Header set Cache-Control "max-age=604800, public" 
    </FilesMatch> 

    # WEEK 
    <FilesMatch "\.(js|css|swf)$"> 
     Header set Cache-Control "max-age=604800" 
    </FilesMatch> 
</IfModule> 

<IfModule mod_deflate.c> 
    SetOutputFilter DEFLATE 
    SetEnvIfNoCase Request_URI \ 
    \.(?:gif|jpe?g|png)$ no-gzip dont-vary 
</IfModule> 

<IfModule mod_expires.c> 
AddType font/ttf .ttf 
AddType font/otf .otf 
AddType font/x-woff .woff 
AddType image/svg+xml .svg 
AddType application/vnd.ms-fontobject .eot 

    ExpiresActive on 
    ExpiresByType image/jpg "access 2 month" 
    ExpiresByType image/gif "access 2 month" 
    ExpiresByType image/jpeg "access 2 month" 
    ExpiresByType image/png "access 2 month" 
    ExpiresByType text/css "access 2 month" 
    ExpiresByType application/x-javascript "access plus 2 month" 
    ExpiresByType text/javascript "access plus 2 month" 
    ExpiresByType application/javascript "access plus 2 month" 
    ExpiresByType image/x-icon "access plus 12 month" 
    ExpiresByType image/icon "access plus 12 month" 
    ExpiresByType application/x-ico "access plus 12 month" 
    ExpiresByType application/ico "access plus 12 month" 

ExpiresByType font/ttf "access plus 12 month" 
ExpiresByType font/otf "access plus 12 month" 
ExpiresByType application/vnd.ms-fontobject "access plus 12 month" 
ExpiresByType font/x-woff "access plus 12 month" 
ExpiresByType image/svg+xml "access plus 12 month" 
</IfModule> 
+1

aus Ihrer Frage Es ist nicht klar, was/wo genau das Problem ist. Bitte posten Sie Ihre volle Htaccess – starkeen

+0

@starkeen Überprüfen Sie meine Htaccess-Code –

+0

Ihre Regeln sind nicht in der richtigen Reihenfolge. Setzen Sie # Dires-Regeln vor den https-Umleitungsregeln nicht berühren. – starkeen

Antwort

1

Dies zwingt alles HTTPs Ausnahme die Verzeichnisse, die Sie in den Klammern angeben:

RewriteEngine On 

#Force everything to HTTPs 
RewriteCond %{HTTP:X-Forwarded-SSL} !on 
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301] 

#Checks if HTTPs is on for foobar & foobar2, if it is, turn it off 
RewriteCond %{HTTP:X-Forwarded-SSL} =on 
RewriteCond %{REQUEST_URI} !^\/(foobar|foobar2) 
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301] 

Sie können so viele Verzeichnisse hinzufügen, wie Sie möchten, trennen Sie sie einfach mit |. Ersetzen Sie foobar & foobar2 usw. mit den Verzeichnissen, die Sie ausschließen möchten.

Verwandte Themen