强制HTTPS中断htaccess中的RewriteRule

时间:2015-09-17 10:41:33

标签: php apache .htaccess mod-rewrite

我遇到了麻烦,我的SEO友好网址正如我想要的那样工作。每当我尝试强制https时,它都会破坏我RewriteRule的所有

#error redirect
ErrorDocument 404 /

Options +FollowSymLinks
RewriteEngine on

#add trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*[^/]$ /$0/ [L,R=301]



#rewrite pages

# Main Site
RewriteRule ^photo/([^/]*)/([^/]*)$ /photo.php?slug=$1 [L]
RewriteRule ^video/([^/]*)/([^/]*)$ /video.php?slug=$1 [L]
RewriteRule ^quote/([^/]*)/([^/]*)$ /quote.php?slug=$1 [L]
RewriteRule ^post/([^/]*)/([^/]*)$ /post.php?slug=$1 [L]
RewriteRule ^author/([^/]*)/([^/]*)$ /author.php?display_name=$1 [L]
RewriteRule ^tag/([^/]*)/([^/]*)$ /tag.php?tag_name=$1 [L]
RewriteRule ^category/([^/]*)/([^/]*)/$ /category.php?slug=$1&page=$2 [L]
RewriteRule ^category/([^/]*)/([^/]*)$ /category.php?slug=$1 [L]
RewriteRule ^blog/$ /blog.php [L]
RewriteRule ^blog/([^/]*)/([^/]*)$ /blog.php?page=$1 [L]
RewriteRule ^edisto/$ /edisto.php [L]
RewriteRule ^edisto/([^/]*)/([^/]*)$ /edisto.php?page=$1 [L]
RewriteRule ^mischief/$ /mischief.php [L]
RewriteRule ^mischief/([^/]*)/([^/]*)$ /mischief.php?page=$1 [L]
RewriteRule ^dynamite-lady/$ /dynamite-lady.php [L]
RewriteRule ^dynamite-lady/([^/]*)/([^/]*)$ /dynamite-lady.php?page=$1 [L]
RewriteRule ^videos/$ /videos.php [L]
RewriteRule ^videos/([^/]*)/([^/]*)$ /videos.php?page=$1 [L]
RewriteRule ^photos/$ /photos.php [L]
RewriteRule ^photos/([^/]*)/([^/]*)$ /photos.php?page=$1 [L]
RewriteRule ^meet-the-crew/$ /meet-the-crew.php [L]
RewriteRule ^check-ins/$ /check-ins.php [L]
RewriteRule ^404/$ /404.php [L]
RewriteRule ^(\d+)/?$ /index.php?page=$1 [L,QSA]

1 个答案:

答案 0 :(得分:1)

只需使用__author__ = 'Dharmjit' def InsertionSort(list): for index in range(1,len(list)): curr = list[index] position = index while position > 0 and list[position-1] > curr: list[position] = list[position-1] position = position - 1 list[position] = curr return list l = [2,1,5,3,9,6,7] print(InsertionSort(l)) [1,2,3,5,6,7,9] 变量重定向:

%{HTTPS}

不是运动几个类似的重写,而是将它们组合成一个:

RewriteEngine On
RewriteCond %{HTTPS} !=on [NC]
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]