Reputation: 39
i have windows hosting and website is in php. So i asked the hosting company where i can find the .htaccess file. and they said there is no .htaccess file in windows hosting i have to use web.config file to do website configuration.
I tried this simple code on my web.config but i got 500 - Internal server error.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
</system.web>
<rewrite>
<rule name="rule 1c" stopProcessing="true">
<match url="^([a-zA-Z]+)$" />
<action type="Rewrite" url="/index.php?category={R:1}" appendQueryString="true" />
</rule>
</rewrite>
</configuration>
Upvotes: 1
Views: 2366
Reputation: 39
Hii thanks for your reply, but i got issue if use your code, i try another way because on index.php i also have catagory of the menus
here is the code
Its working when i write as : mysite.com/sport (mysite.com/index.php?category=sport), mysite.com/clothes (mysite.com/index.php?category=clothes) etc..
but when i write as mysite.com/index then it treated as mysite.com/index.php?category=index
<rule name="Catagary" stopProcessing="true">
<match url="^([a-zA-Z]+)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/index.php?category={R:1}" appendQueryString="true" />
</rule>
<rule name="Gallery" stopProcessing="true">
<match url="^([a-zA-Z0-9_-]+)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="gallery.php?id={R:1}" appendQueryString="true" />
</rule>
<rule name="RewritePHP">
<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="{R:1}.php" />
</rule>
</rules>
Upvotes: 1
Reputation: 418
Here is the web.config that I use to hide index.php, hope this will help.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect index.php" stopProcessing="true">
<match url="index\.php/(.*)" />
<action type="Redirect" url="\?{R:1}" appendQueryString="false" />
</rule>
<rule name="Rewrite index.php">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Upvotes: 2