简体   繁体   中英

Apache RewtireRule doesn't save URL after redirect

I'm currently trying to make Apache RewriteRule. The main idea is a user type in a browser

sensors.com/erd-admin

Apache should redirect it to the address

158.22.22.14/erd-admin

But I get in a browser URL -

158.22.22.14/erd-admin

How to save the domain name in a browser?

The final URL should be -

sensors.com/erd-admin

I was trying to make it like:

RewriteRule ^erd-admin http://158.22.22.14/erd-admin/$1 [P]

but always get IP address instead of the domain address.

Big thank you!

After a lot of pain, I found how to implement it.

The first step is to create a CNAME record for the IP.

158.22.22.14 CNAME erd-admin.sensors.com

The second step is to add the rewrite rule to .htaccess:

RewriteRule ^erd-admin(.*) http://erd-admin.sensors.com/erd-admin $1 [P]

The third step in Virtual host config add ProxyPassReverse

ProxyPassReverse / http://erd-admin.sensors.com/

Thank you all.

Regards,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM