My url like this : https://myhospital.com/Hospitals-and-Clinics/Hospitals/Hospital-A/Our-Doctors
I try this script :
<location path="Our-Doctors">
<system.webServer>
<httpRedirect enabled="true" destination="https://www.appointment.myhospital.com/" httpResponseStatus="Permanent" />
</system.webServer>
</location>
in the web config
But it does not works. It does not redirect to https://www.appointment.myhospital.com/
Hospital-A is name of hospital
So it can like this :
https://myhospital.com/Hospitals-and-Clinics/Hospitals/Hospital-B/Our-Doctors
or
https://myhospital.com/Hospitals-and-Clinics/Hospitals/Hospital-C/Our-Doctors
It's dynamic
How can I solve this problem?
Is using a regular expression for this case?
Your config does not work because you are wrong path. It must be
<location path="Hospitals-and-Clinics/Hospitals">
You can use URL Rewrite Module module in your case. like this:
<rule name="Demo" stopProcessing="true">
<match url="\/Our-Doctors$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)?myhospital\.com$" />
</conditions>
<action type="Redirect" url="https://www.appointment.myhospital.com/" />
</rule>
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.