we migrate our webapp hosted in a directory "webapp" inside main domain:
http://www.example.com/webapp/
To the new subdomain without "webapp" folder:
http://subdomain.example.com/
I need to redirect only subdir "webapp". I don't want to redirect other url like http://www.example.com/
, http://www.example.com/folder1
, http://www.example.com/folder2
, ....
But we have already sent a lot of emails to customers with link inside like: <a href="http://www.example.com/webapp/login">LOGIN TO YOUR DASHBOARD</a>
or other link like <a href="http://www.example.com/webapp/data/download.php/id=xxx">DOWNLOAD YOUR DOC</a>
Now i'm trying to do a redirect trough web.config but it seem that nothing work.
If I try no navigate to, for example, http://www.example.com/webapp/login
i don't get redirected to http://subdomain.example.com/login/
as expected.
If I try no navigate to, for example, http://www.example.com/webapp/data/download.php/id=43
i don't get redirected to http://subdomain.example.com/data/download.php/id=43
as expected.
Any suggest?
<rule name="redirect-to-subdomain" stopProcessing="true">
<match url="^webapp/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" url="http://subdomain.example.com/{R:0}" redirectType="Permanent" />
</rule>
You rule won't work except for http://www.example.com/webapp/ .
If you want to redirect link like http://www.example.com/webapp/login . Please try this rule.
<rule name="redirect-to-subdomain" stopProcessing="true">
<match url="^webapp/(.*)$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" url="http://subdomain.example.com/{R:1}" redirectType="Temporary" />
</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.