Здравствуйте.
В процессе переноса древненького сайта PHP с Windows сервера + IIS на Linux + Apache + .htaccess, появилась надобность перевести несколько перенаправлений из формата IIS web.config в Apache .htaccess.
Несколько из них удалось самому переписать, но остались некоторые с которыми не могу справится.
Помогите, пожалуйста.
Правила web.config:
<rule name="Rule1" enabled="true" stopProcessing="true">
<match url="^switch\.php$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^lang=([^=&]+)$" />
</conditions>
<action type="Redirect" url="switch/{C:1}" appendQueryString="false" />
</rule>
<rule name="Rule2" enabled="true" stopProcessing="true">
<match url="^switch/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="switch.php?lang={R:1}" />
</rule>
<rule name="Rule3" stopProcessing="true">
<match url="^zone-client/index\.php$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
</conditions>
<action type="Redirect" url="zone-client/index" appendQueryString="false" />
</rule>
<rule name="Rule4" stopProcessing="true">
<match url="^zone-client/index$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="zone-client/index.php" />
</rule>
<rule name="Rule5" stopProcessing="true">
<match url="^index\.php$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^slug=([^=&]+)$" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
<rule name="Rule6" stopProcessing="true">
<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?slug={R:1}" />
</rule>
<rule name="Rule7" stopProcessing="true">
<match url="^index\.php$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern="^slug=([^=&]+)&details=([^=&]+)$" />
</conditions>
<action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" />
</rule>
<rule name="Rule8" stopProcessing="true">
<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?slug={R:1}&details={R:2}" />
</rule>
Мои (по)пытки их переписать в .htaccess:
#Rule1
RewriteCond %{REQUEST_METHOD} !POST
RewriteRule ^translation\.php(.*) /translation? [R=302,L]
#Rule2
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^translation(.*) /translation.php [R=302,L]
#Rule3
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} ^lang=&$
RewriteRule ^switch\.php(.*) /switch/%1 [R=302,L,B]
#Rule4
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^zone-client/index(.*) /zone-client/index.php [R=302,L]
#Rule5
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} ^slug=&$
RewriteRule ^index\.php(.*) /%1 [R=302,L,B]
#Rule6
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/?$ /index.php?slug=$1 [R=302,L]
#Rule7
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} ^^slug=&;details=&$
RewriteRule ^index\.php(.*) /%1/%2 [R=302,L,B]
#Rule8
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/(.*)/?$ /index.php?slug=$1&details=$2 [R=302,L]