2

I have a Plesk account for my website hosting. I don't know anything about web.config files but I am trying to remove .HTML extensions from my URLs. I tried a solution (written later in the post), but it worked perfectly for all URLs but the home page. My home page shows the following error:

Server Error in '/' Application.

Runtime Error

(There is much more text in the error above, but I am trying to keep the question as brief as possible)

When I use www.xyz.com it shows the error. When using www.xyz.index.html, it works fine but the URL I see then becomes www.xyz.index, which is unpleasant to look at. Please refer to this post below and help me with a solution if you can!

Remove HTML extension with web config permanently

Code that is written as the best answer to the post above and also the one I am using:

<configuration>   
    <system.webServer>   
        <rewrite>
            <rules>
                <rule name="Hide .html ext">
                    <match ignoreCase="true" url="^(.*)"/>
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                        <add input="{REQUEST_FILENAME}.html" matchType="IsFile"/>
                    </conditions>
                    <action type="Rewrite" url="{R:0}.html"/>
                </rule>
                <rule name="Redirecting .html ext" stopProcessing="true">
                    <match url="^(.*).html"/>
                    <conditions logicalGrouping="MatchAny">
                        <add input="{URL}" pattern="(.*).html"/>
                    </conditions>
                    <action type="Redirect" url="{R:1}"/>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

1 Answers1

0

Ah, I see what's wrong. It's either you forgot to put a /, or because it is a folder, or it is because you used many domains.

  • Hi! I am using just one domain name. Could you please explain to me the impact a / or a folder could have? – Jay Gadekar Sep 30 '20 at 02:11
  • A / can change it. For example, it may have been . Then you could have changed it to . A solution is to do (Rename the / property!) – Display My Name Sep 30 '20 at 18:04
  • If you are suggesting that I add a suffix to my homepage, then that isn't what I am looking for as a solution. I am aware that www.xyz.com/home will work but I don't want to do so. I want it to be www.xyz.com only and have other pages as www.xyz.com/abc – Jay Gadekar Oct 01 '20 at 13:07
  • Welcome to SO! Please read the [tour](https://stackoverflow.com/tour), and [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer) – Tomer Shetah Oct 08 '20 at 10:02