When I've used Apache, I used .htaccess to redirect a custom path to a certain page.
But my new site is hosted on a Windows server and I cant find any help on setting up redirects for old pages which have been deleted for new pages.
Example. When people visit
[domain]/ValveMonitoring/valveleak.php
They should be forwarded to
[domain]/valve-monitoring/midas-meter.php
Can someone help?
The rewrite is the way to do this as codechurn points out. Here is an example of what you can stick in the web.config at the root of the site. Its really quite simple:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="TestRewrite">
<!-- The match is a regex, hence the escaped '.' -->
<match url="someFile\.php" />
<action type="Redirect" redirectType="Permanent" url="PHPisSilly.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
You will have to make sure the rewrite module is installed. On Win10 go here to make sure:
Control Panel -> Programs -> Programs and Features -> Turn Windows features on or off -> Internet Information Services -> World Wide Web Services -> Common HTTP Features
And just enable all those options under "Common HTTP Features" and you should be good to go (except maybe Directory Browsing and WebDAV Publishing). Press OK and close.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With