I have a webpage hosted on a shared Microsoft-IIS/8.5 server. I don't have the admin privileges on that server, and I don't have access to its configuration files, so I can't really make sure that the URL rewrite module or the HTTP redirect element are correctly installed / set up.
I would like to establish a redirection from a folder named old_folder
to a folder named new_folder
(both at the root for me, i.e., at http://sharedhosting.com/myusername/).
I placed in the root folder the following web.config
file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<sectionGroup name="system.webServer">
<sectionGroup name="rewrite">
<section name="rules" overrideModeDefault="Allow" />
</sectionGroup>
</sectionGroup>
</configSections>
<system.webServer>
<rewrite>
<rules>
<rule name="attempt" stopProcessing="true" enabled="true">
<match url="^old_folder/$" />
<action type="Redirect" url="new_folder/" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
But all I can get is a 403 - Forbidden: Access is denied.
(if I leave an empty old_folder
) or a 404 - File or directory not found.
(if I erase it).
I tried using the HTTP Redirect
, by placing in old_folder
a Web.config
file containing
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="http://sharedhosting.com/myusername/new_folder/" />
</system.webServer>
</configuration>
But that didn't worked either.
I know that my Web.config
files are read (I can get 500 errors if there is an error in them). I suspect that the URL rewrite is installed, since, for instance, http://sharedhosting.com/myusername/folder
is rewritten to http://sharedhosting.com/myusername/folder/
(i.e., with a slash) if the folder
folder exists.
Is my rule correct? Does my host prevent me from redirecting? If yes, how can I tell?
I added a <clear />
after the <rules>
tag to discard all the other rewriting rules, but it still isn't redirecting anything.
What am I missing?
LAST EDIT BEFORE THE BOUNTY EXPIRES To clarify, my question is "How to understand why the server isn't correctly interpreting / ignoring my instructions?".
We came to the conclusion that it was probably my server that was weirdly set-up, I'm precisely trying to "revert-engineer" that and to detect what's making the server ignore the redirect / rewrite rules.