2017-03-20 7 views
1

以下のコードはHTTP URLがhttpsにリダイレクトされていない以外は正常に動作します。完全なhttps URLに正しくリダイレ​​クトされています。httpがhttpsにリダイレクトされていますが、動作していません100%

ここで、httpリダイレクトが機能しない方法を参照してください。 http://www.jamavarrestaurants.com/s/6/mayfair-private-dining-with-private-room

ここで働いていますが、私たちはURLにsection.phpを入れません。 http://www.jamavarrestaurants.com/section.php/6/mayfair-private-dining-with-private-room

注:問題を混乱させるだけで、SEFチェックとURL構造を含むsection.phpファイルがコピーされ、現在使用されているか、または使用されるコピー "s.php"が作成されました。 products.php、article.php、およびdiscount.phpと同じです。

ご協力いただければ幸いです。

#Header append X-FRAME-OPTIONS "SAMEORIGIN" 
RewriteEngine On 
RewriteBase/

## HTTP > HTTPS (only works for this format 
http://www.jamavarrestaurants.com/section.php/3/1/mayfair-restaurant) 
## see: http://www.codexworld.com/redirect-non-www-to-www-http-to-https- 
using-htaccess-file/ 
RewriteCond %{HTTPS} !on [OR] 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule^https://www.jamavarrestaurants.com%{REQUEST_URI} [NE,L] 

## RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 
# RewriteRule ^index\.php$ https://www.jamavarrestaurants.com/ [R=301,L] 
# 
## Added beciause the catch all 404 redirect was sending to /index 
# RewriteRule ^index?$ https://www.jamavarrestaurants.com [L,R=301,NC] 
# 
### JSHOP CORE REWRITE RULES ### 
################################ 
#<IfModule mod_rewrite.c> 

Options +SymlinksIfOwnerMatch +MultiViews 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*?).php/(.*?) $1.php?$2 
## special rewrite rules for shortened urls ## 
RewriteRule ^section.php/(.*) /s/$1 [R=301,L] 
RewriteRule ^section/(.*) /s/$1 [R=301,L] 
# 
### To remove section page if 1 which is default for most (unless products 
span more) 
RewriteRule ^s.php/(.*)/1/(.*) /s/$1/$2 [R=301,L] 

#RewriteRule ^s/(.*)/1/(.*) /s/$1/$2 [R=301,L] 
# 
RewriteRule ^product.php/(.*) /p/$1 [R=301,L] 
RewriteRule ^product/(.*) /p/$1 [R=301,L] 
RewriteRule ^article.php/(.*) /a/$1 [R=301,L] 
RewriteRule ^article/(.*) /a/$1 [R=301,L] 
RewriteRule ^discount.php/(.*) /d/$1 [R=301,L] 
RewriteRule ^discount/(.*) /d/$1 [R=301,L] 

#</IfModule> 
########################### 
# The rest 
############################ 

答えて

1

ルールをリファクタリングして並べ替えます。 .htaccessを次のように置き換えてください。

Options +SymlinksIfOwnerMatch +MultiViews 
RewriteEngine On 
RewriteBase/

## HTTP > HTTPS (only works for this format 
RewriteCond %{HTTPS} !on [OR] 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(\S*)\sHTTP [NC] 
RewriteRule^https://www.jamavarrestaurants.com/%1 [NE,L,R=301] 

## special rewrite rules for shortened urls ## 
RewriteRule ^section(?:\.php)?/(.*)$ /s/$1 [R=301,L] 

### To remove section page if 1 which is default for most (unless produccts span more) 
RewriteRule ^s\.php/(.*)/1/(.*) /s/$1/$2 [R=301,L] 

RewriteRule ^product(?:\.php)?/(.*)$ /p/$1 [R=301,L] 

RewriteRule ^article(?:\.php)?/(.*)$ /a/$1 [R=301,L] 

RewriteRule ^discount(?:\.php)/(.*)$ /d/$1 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*?)\.php/(.*)$ $1.php?$2 [L,QSA] 

この変更をテストする前に、ブラウザのキャッシュを完全にクリアしてください。


curlテスト出力:

curl -kI -A "Chrome" 'http://www.jamavarrestaurants.com/s/5/mayfair-food-and-wine-menus' 
HTTP/1.1 301 Moved Permanently 
Date: Mon, 20 Mar 2017 21:40:31 GMT 
Server: Apache 
Location: https://www.jamavarrestaurants.com/s.php/5/mayfair-food-and-wine-menus 
Content-Type: text/html; charset=iso-8859-1 
+0

おかげで、内部サーバーエラー – Puzzel

+0

を与えていただきありがとうございます。今は動作しますが、httpは完全なURLにリダイレクトされません。http://www.jamavarrestaurants.com/s/5/mayfair-food-and-wine-menus – Puzzel

+0

これはすべての歴史的なインバウンドリンクが壊れることです。 – Puzzel

関連する問題