LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 July 2 2015

ironman
Member

Removing Index.php from URL

Hey Guys,

A client called me a week ago saying that their website is down ...
It's a PHP website hosted on an IIS server.

The problem was "The Service is unavailable" just black text on a white background.
I tried restoring files ... etc nothing worked.

After troubleshooting, it appeared that the problem is from the web.config file, it was a custom web.config file that i found from the internet which aims at omitting index.php from the URL

so instead of typing

www.blog.com/index.php/contactus
i write
www.blog.com/contactus

So when removing this web.config, the website loads but we need to add index.php before the end of the URL.

i have tried several versions of this web.config file which aims at rewriting URL's but the result was always "Service is Unavailable"

Any help would be appreciated.

PS: I am not a developer.

PS2: this is the rule i am using (which is failing)

<?xml version="1.0"?>
<configuration>
   <system.webServer>
      <rewrite>
         <rules>
            <rule name="Main Rule" stopProcessing="true">
               <match url=".*" />
               <conditions logicalGrouping="MatchAll">
                 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
               </conditions>
               <action type="Rewrite" url="index.php" />
            </rule>
         </rules>
      </rewrite>
   </system.webServer>
</configuration>

Last edited by ironman (July 2 2015)

Offline

#2 July 2 2015

ironman
Member

Re: Removing Index.php from URL

UPDATE: Guys Probably the web.config is correct, but i just called IDM (Hosting Provider), they said that they did some changes to the website and they probably stopped Mod_rewrite module.

Offline

#3 July 2 2015

rolf
Member

Re: Removing Index.php from URL

I hate joomla.
BTW mod_rewrite is an Apache thing. Its called something else on IIS.
I am not an IIS guy but I think your problem is on this line:

<action type="Rewrite" url="index.php" />

I think this will replace the url with only index.php
I dont see any place where "contactus" or anything else is injected in this string.
What happens if you type www.blog.com/index.php ?
Or maybe its replacing the whole address with the domain too.

Last edited by rolf (July 2 2015)

Offline

#4 July 3 2015

ironman
Member

Re: Removing Index.php from URL

Thanks guys it got resolved, IDM includes a default web.config that has two rules, so instead of replacing the whole config file with the one posted above, i just pasted the rules from the one above and pasted them in IDM's defaut web.config.

Everything worked.

Thanks rolf

Offline

#5 July 3 2015

rolf
Member

Re: Removing Index.php from URL

ironman wrote:

Thanks rolf

You are welcome

Offline

Board footer