私は以下の.htaccessファイルを用意していますが、最適ではない(おそらく少しは価値があります)ということはわかっています。サブドメインを無視するように既存の.htaccessを変更します
# Prevents public viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Custom 404 page
ErrorDocument 404 https://www.domain.com/404/
# Turn on rewriting and set rewriting base
RewriteEngine On
RewriteBase/
# Force WWW
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^([^.]+)\.([a-z]{2,4})$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
# Force WWW and HTTPS
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule^https://www.domain.com%{REQUEST_URI} [R=301,L]
# Remove .php extension
RewriteRule ^(properties)/(all|location1|location2|location3)/(all|1|2|3|4|5|6|7|8|9)/(asc|desc) $1.php?location=$2&bedrooms=$3&sort-by=$4
RewriteRule ^(properties)/(all|location1|location2|location3)/(all|1|2|3|4|5|6|7|8|9) $1.php?location=$2&bedrooms=$3
RewriteRule ^(properties)/(all|location1|location2|location3) $1.php?location=$2
RewriteRule ^(view-property)/(.*)/(print-view) $1.php?id=$2&print=true
RewriteRule ^(view-property)/(.*)/ $1.php?id=$2
RewriteRule ^(.*)/$ $1.php
私たちの新しいWebサイトは、テスト用に新しく作成されたステージング環境にプッシュされる準備が整いました。この場合、staging.domain.com
になりますが、このステージングURLに実際にアクセスする際に問題が発生しています。
EDIT - 明らかにするには、staging.domain.com
にアクセスすると、https://www.domain.com
にリダイレクトされるという問題があります。
この問題は、上記の書き換えルールが原因であると考えられます。
RewriteCond %{HTTP_HOST} !^staging\.domain\.com
かのような新しい条件/ルールを追加:
RewriteCond %{HTTP_HOST} ^staging\.domain\.com [NC]
RewriteRule ^(.*) - [L]
残念ながら、これらのどれも私はいくつかの可能な解決策のような既存の書き換えルールに追加条件を追加することなどが研究しています働いています。 .htaccess
ファイルを使って作業することは、実際には私の強い訴訟ではありません。
P.S.新しいサイトはLaravel 5.3によって強化されていますので、私たちがライブに行くときに、ルールを書き直すという恐ろしい試み(最下位のもの)を取り除くことになります!上とライブサイトが期待どおりに動作し続けながら説明するよう、私はルールを変更した
# Turn on rewriting and set rewriting base
RewriteEngine On
RewriteBase/
# Force WWW and HTTPS
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule^https://www.%1%{REQUEST_URI} [R=301,L,NE]
# Remove .php extension and rest of the rewrite rules
、ステージングURL ': –
使い方 'curl'は以下を返します:' <!DOCTYPE HTML PUBLIC " - // IETF // DTD HTML 2.0 // EN">
移動永久
移動しました。 –
あなたの.htaccessにまだリダイレクトルールがありますか?私の答えは、 'https:// www.tynesidelettings.com /' – anubhava