I have a site which is accessible both by these urls inside my domain:
http://test
http://test.mydomain.com
I'm trying to set up a redirect from http://test
to http://test.mydomain.com
using url rewriting, this is the rule I have at the moment:
<rule name="domain redirect" enabled="true" stopProcessing="true">
<match url="^test(.*)$" />
<action type="Redirect" url="http://test.mydomain.com/{R:0}" appendQueryString="true" />
</rule>
But it creates redirect loop. I know there is something small I'm missing, can anyone help?
Thank you
You can create a file (if it's not already created) called ".htaccess" without quotes and put in the following code (changing "test" and "mydomain", of course):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^test\.com$ [NC]
RewriteRule ^(.*)$ http://test.mydomain.com$1 [L,R=301]
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.