2015-09-17 86 views
0

我遇到了麻煩,我有我的SEO友好的URL完全按照我想要的方式工作。每次我試圖迫使HTTPS它打破了我所有的RewriteRule強制HTTPS中斷htaccess中的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] 
+0

我沒有注意到你_forcing_ https的任何地方。 – hjpotter92

回答

1

的只需用%{HTTPS}變量重定向:

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

相反的運動幾個類似的重寫,將它們組合成一個單一的一個:

RewriteRule ^(photo|videos?|quote|post|author|...)/([^/]+)/.+$ /$1.php?slug=$2 [L] 
RewriteRule ^(blog|check-ins|videos|photos|...)/$ $1.php [L] 
+0

我在HTTPS的'.htaccess'的頂部嘗試了你的重寫,但它仍然給出錯誤,這就是Apache日誌踢出來的:'協商:發現匹配請求的文件:/ var/www/post (不可協商)。' –

+0

@JeffThomas檢查您是否在任何地方啓用了「MultiViews」。如果是這樣,請禁用它。 – hjpotter92