Not redirecting the subdomain using .htaccess

2019-09-03 17:02发布

问题:

I have site which uses wordpress and I usually login as : mydomain.com/wp-admin . I want it to be on the subdomain . I have tried to create a subdomain by using the following rewrite url :

RewriteCond %{HTTP_HOST} ^wp-admin
RewriteCond %{REQUEST_URI} !^/wp-admin
RewriteRule ^(.*)$ wp-admin/$1 [L]

But when I am trying to reachhttp://wp-admin.mydomain.com/ a weired page comes out saying an error message :

If you feel you have reached this page in error, please contact the web site owner:

And the url changes to :

http://wp-admin.mydomain.com/cgi-sys/defaultwebpage.cgi

Please help how could I be able to create a subdomain .

回答1:

You could try to give an absolute path, and to enforce an internal redirect (aka. pass-through).

RewriteRule ^(.*)$ /wp-admin/$1 [PT,L]
                   ^             ^^