Перенаправление URL-адреса папки webroot в cakephp - PullRequest
0 голосов
/ 07 июня 2018

Я пытаюсь перенаправить URL-адрес папки webroot, то есть

https://test.example.com/ to https://www.example.com/test

, где test => папка webroot.

Iпробовал перенаправление в webroot / .htaccess

<IfModule mod_rewrite.c>

RewriteEngine on
Redirect 301 /http://test.example.com http://example.com/test
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

</IfModule>

и пробовал следующее:

<IfModule mod_rewrite.c>
Options +FollowSymLinks 
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^https://test.example.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/test/ [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

Пожалуйста, помогите мне решить эту проблему ..

Ответы [ 2 ]

0 голосов
/ 07 июня 2018

Попробуйте с ниже,

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(.+)\.example.com
RewriteRule ^ https://www.example.com/%1%{REQUEST_URI} [L,R=301]
0 голосов
/ 07 июня 2018

Это будет работать:

<IfModule mod_rewrite.c>

RewriteEngine on
Redirect 301 / http://example.com/test/
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

</IfModule>
...