前提
XServerのに以下のようなディレクトリを構成しています。
public_html ┬ production ┬ index.html │ ├ service.html │ ├ favicon.ico │ ├ style.css │ ├ images │ ├ js │ ├ font │ └ css │ ├ staging ─ index.html │ └ .htaccess
.htaccess
には以下のように記載しています。
RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^.*/index.(html|php) RewriteRule ^(.*)index.(html|php)$ https://%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{REQUEST_URI} !^/staging/ RewriteRule ^(.*)$ /production/$1 [L]
実現したいこと
https://~~~.com/~~~
にアクセスした際にproduction配下のファイルを表示(URLはそのまま)したい- 例えば、
https://~~~.com
にアクセス →production/index.html
の内容を表示 - 例えば、
https://~~~.com/service.html
にアクセス →production/service.html
の内容を表示
- 例えば、
https://~~~.com/staging/~~~
にアクセスした際にstaging配下のファイルを表示したい- 例えば、
https://~~~.com/staging
にアクセス →staging/index.html
の内容を表示 - 例えば、staging配下をproduction配下のファイル構成と同じにした場合、
https://~~~.com/staging/service.html
にアクセス →staging/service.html
の内容を表示
- 例えば、
発生している問題・エラーメッセージ
stagingの方はアクセス可能だが、productionのほうはinternal errorになる。
試したこと
RewriteRule ^(.*)$ /production/$1 [L]
を RewriteRule ^(.*)$ /staging/$1 [L]
に書き換えてhttps://~~~.com
にアクセスすると staging/index.html
が表示された。
> productionのほうはinternal errorになる。
https://www.xserver.ne.jp/manual/man_server_logerror.php を参考にエラーログの内容を確認して、「internal error」時の詳細なエラーメッセージを確認してください。