。htaccess重定向而不更改同一主机的URL

问题描述 投票:0回答:1

我想重定向面板内的子域,子域editor.domain.com

它应该重定向到domain.com/cmseditor

但是访客应该看到editor.domain.com

到目前为止,我已经尝试过:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^editor\.homecatering\.pt$ [NC]
RewriteRule ^ http://homecatering.pt/cmseditor%{REQUEST_URI} [L,R=301]
apache .htaccess server cpanel
1个回答
0
投票

尝试这样的事情:

RewriteEngine On

 # If the subdomain is "editor.homecatering.pt"
 RewriteCond %{HTTP_HOST} ^editor.homecatering.pt$ [NC]
 # Then rewrite any request to directory /cmseditor
 RewriteRule ^((?!cmseditor).*)$ /cmseditor/$1 [NC,L]

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^\.]+)\.homecatering\.pt$ [NC]
RewriteRule ^(.*)$ http://homecatering\.pt/cmseditor/%1
© www.soinside.com 2019 - 2024. All rights reserved.