Page 1 of 1

htaccess to web config problem

Posted: Fri May 04, 2012 3:32 am
by pieee
Hey guys,

I am having a bit of trouble getting my .htaccess converted to a web.config file to run on IIS instead of Apache. The current web.config file I have come up with is failing and giving me a 500 error on the server.

Can anyone tell me where i am going wrong? The following is my code for both files.

The following code is for the .htaccess that I need to convert

Code: Select all

DirectoryIndex index.php index.html index.htm

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1

ErrorDocument 404 /errors/404.php
ErrorDocument 403 /errors/403.php
ErrorDocument 500 /errors/500.php
</IfModule>

Options -Indexes
Options +FollowSymlinks

<Files .htaccess>
deny from all
</Files>
and This is the code for the we.config that isn't working properly

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
	<files>
		<remove value="index.php" />
		<add value="index.php" />
	</files>
</defaultDocument>

<rewrite>
  <rules>
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^index.php?page=$1$" />
      </conditions>
      <action type="Redirect" redirectType="Permanent" url="index.php?page=$1" />
    </rule>
    <rule name="Imported Rule 2" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
        <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="index.php?page=$1" appendQueryString="true" />
    </rule>
  </rules>
</rewrite>

<httpErrors>
   <remove statusCode="404" subStatusCode="-1" />
   <error statusCode="404" prefixLanguageFilePath="" path="/errors/404.php" responseMode="ExecuteURL" />
   <remove statusCode="403" subStatusCode="-1" />
   <error statusCode="403" prefixLanguageFilePath="" path="/errors/403.php" responseMode="ExecuteURL" />
   <remove statusCode="500" subStatusCode="-1" />
   <error statusCode="500" prefixLanguageFilePath="" path="/errors/500.php" responseMode="ExecuteURL" />
</httpErrors>

<directoryBrowse enabled="false" />

</system.webServer>
</configuration>

Re: htaccess to web config problem

Posted: Fri May 04, 2012 3:40 am
by requinix
What does IIS's log(s) say about those 500 errors?

Re: htaccess to web config problem

Posted: Fri May 04, 2012 3:45 am
by pieee
This is the message I am receiving:


500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

Re: htaccess to web config problem

Posted: Fri May 04, 2012 3:47 am
by pieee
What I am trying to achieve is having the site only display the foldername of the files location e.g. the processmeters.php file is in the process-meter folder, so what I would like my url to display is yadayada.com/folder/process-meter

EDIT: Sorry I missed the word log(s), I dont have access to those as it is my universities server and we can only upload to it. Which is why i figured that it was an IIS server after my upload didnt work as my home server is Apache

Re: htaccess to web config problem

Posted: Tue May 15, 2012 2:20 am
by n4d3r
please convert and send to nader_moradi69@yahoo.com mail.
tnx for all.
RewriteEngine on
Options +FollowSymlinks
RewriteRule ^(.*).html$ $1.php [nc]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(css|pdf|gif|ico|jpg|js|png|swf|pdf|txt|php)$
RewriteRule ^(.*)/(.*)$ main.php?$1=$2 [L,QSA]