I'm having trouble converting a IIS rewrite rule to Apache.
The purpose of the rule is to redirect domain.com/c/name/
to domain.com/?company=name
.
It should also redirect domain.com/c/name/?page=me
to domain.com/?page=me&company=name
.
This is the original IIS web.config file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="multi-company management" enabled="true">
<match url="^c/(.+?)/(.*)" />
<action type="Rewrite" url="{R:2}?company={R:1}" logRewrittenUrl="false" />
</rule>
</rules>
</rewrite>
<tracing>
<traceFailedRequests>
<add path="*">
<traceAreas>
<add provider="WWW Server" areas="Rewrite" verbosity="Verbose" />
</traceAreas>
<failureDefinitions statusCodes="200-399" />
</add>
</traceFailedRequests>
</tracing>
</system.webServer>
</configuration>
The apache url I came up with gives the error ERR_TOO_MANY_REDIRECTS
and is the following:
RewriteEngine on
RewriteRule ^c/(.+?)/(.*)$ /$2?company=$1
I think i'm almost there but lacking something to avoid keep redirecting. I think the rule keeps matching on every request. Any help would be greatly appreciated.