Hi im getting these errors when im trying to to convert this file in IIS mod_rewrite
This directive was not converted because it is not supported by IIS:
RewriteBase /php-login/
And
The condition pattern is not supported: -l
Options -MultiViews
RewriteEngine On
RewriteBase /php-login/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
Here it is in XML view with the errors please have a look at the errors
<rewrite>
<!--This directive was not converted because it is not supported by IIS: RewriteBase /php-login/.-->
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.+)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<!--The condition pattern is not supported: -l.-->
</conditions>
<action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
So the features in question are probably not supported by IIS and you
either have to do without them or figure out how to replace them with
whatever is supported. You may want to reformulate your question
accordingly. – SVD Mar 19 at 22:17
Related
I have the following .htaccess file in my website - I'm having to relocate it to a windows IIS machine and having problems with using the URL-Rewrite module to import a rule and create a web.config file.
This is my .htaccess file
# Rewrite URLs and direct to index.php
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
##
## If moving host, change the structure below to folder name of where public folder lives
##
RewriteBase /foldername/public
##
##
##
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>
It fails on the RewriteBase but this I understand in the .htaccess file is crucial for my site to function.
Can anyone give me anyone pointers?
It will convery to below url rewrite rule:
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.+)$" ignoreCase="false" />
<conditions>
<!--##-->
<!--## If moving host, change the structure below to folder name of where public folder lives-->
<!--##-->
<!--##-->
<!--##-->
<!--##-->
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/foldername/public/index.php?url={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
The RewriteBase directive sets the URL-path for relative path substitutions (overriding the directory-prefix). So, instead of using the RewriteBase directive, you could simply hardcode the URL-path in the RewriteRule directive itself.
For example:
RewriteRule ^(.+)$ /foldername/public/index.php?url=$1 [QSA,L]
Currently, I am having issues with IIS server.
When I try to do a login call to my controller (Slim library) the returned value is the base ./index.php file.
The code surely works. I developed the code on Apache environment. I have a live hosted version on an Apache server also, so I suspect the problem can only be from IIS configuration.
This is what I have in web.conf
<rewrite>
<rules>
<rule name="Rewrite fall back 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="/" />
</rule>
</rules>
</rewrite>
This is what works on the Apache server in .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php
RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
The last line is not needed, and I already used the IIS tool to convert .htacces to web.config, but still the behaviour was the same even though the rules were a bit different in the <rewrite> zone.
I can not remove the index.php from url in IIS. Here my .htaccess file;
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
also i tried the steps from codeigniter link but it didn't work for my server. it says only for apache servers. but im using iis server. even i enabled rewrite module but it didnt work again.
You should include this in your Web.config which is located in the root of your project:
<rule name="Remove index" 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>
I need to convert .htaccess to web.config in order to run php on iis 7. Any Ideas?
Options +FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /test
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php
The URL Rewriting module's import rules from .htaccess wizard generated the following rules:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="non-existent paths to index.php">
<match url="^test/(.+)$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="test/index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The request /test/ will cause IIS to fire /test/index.php so (.*) is unnecessary and (.+) is more appropriate.
I'm looking for a way to convert my IIS rewrite rules to an .htaccess file. I couldn't find any tool to automatically do this and all I can get myself is 500 Internal Server Errors.
The web.config file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="RemoveTrailingSlash" stopProcessing="true">
<match url="^(.*?)/+$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:1}" />
</rule>
<rule name="HaltOnTinyMCE" stopProcessing="true">
<match url="^tinymce/.*$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="None" />
</rule>
<rule name="RewriteContent" enabled="true" stopProcessing="true">
<match url="^.*\.(gif|jpg|png|css|js|swf|txt|xml)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="domains/{HTTP_HOST}/{R:0}" appendQueryString="true" logRewrittenUrl="false" />
</rule>
<rule name="RewritePages" enabled="true">
<match url="^.*$" ignoreCase="true" negate="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="index.php" logRewrittenUrl="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
My best try at manually converting this is still giving me the 500 Internal Server Error. Any suggestions?
RewriteEngine on
RewriteCond /+$
RewriteRule ^(.*?)/+$ http://{HTTP_HOST}/$1 [R=301,L]
RewriteCond ^tinymce/.*$
RewriteRule ^(.*)$ $1 [L]
RewriteCond \.(gif|jpg|png|css|js|swf|txt|xml)$
RewriteRule ^.*\.(gif|jpg|png|css|js|swf|txt|xml)$ domains/{HTTP_HOST}/$1 [L]
RewriteRule ^.*$ index.php
Thanks in advance!
You were heading in the right direction, but there were a few errors, and unneeded things. This is what I came up with:
RewriteEngine on
RewriteBase /
#remove tailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [R=301,L]
# stop rules below from being applied if url starts with tinymce/
RewriteRule ^tinymce/.*$ - [L]
#rewrite images etc. to domains folder (unless url already starts with domain/)
RewriteCond $0 !^domains/
RewriteRule ^.*\.(gif|jpg|png|css|js|swf|txt|xml)$ domains/%{HTTP_HOST}/$0 [L]
#catch all other (I added 2 rewriteconds, to prevent rewriting existing files (including index.php))
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php