简体   繁体   中英

How to redirect URL

How to redirect url from

www.example.com/file.html

to

www.example.com/folder/file.html

using .htaccess and web.config

I have been searching for hours and have found several topics but none works for us

For IIS:

Open web.config in the directory where the old page resides. Then add code in web.config there for the old location path and new destination as follows:

<configuration>
  <location path="file.html">
    <system.webServer>
      <httpRedirect enabled="true" destination="www.example.com/folder/file.html" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>  
</configuration>

For apache:

Add in .htaccess the following line:

Redirect /file.html http://example.com/folder/file.html

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