简体   繁体   中英

Converting web.config rules to .htaccess

I have to convert another web.config set of rules to .htaccess and I wanted to make sure that I got the conversion right. There is currently no way for me to test whether it works hence my reason coming to stack overflow. If anyone could help me by confirming my conversion or helping me out where I missed something. Thank you!

webn.config rules

<rule name="Rewrite to controller.php" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="^(developers.)" />
    <add input="{REQUEST_URI}" pattern="^/([_0-9a-z-]+)/controller.php" />
  </conditions>
  <action type="Rewrite" url="\controller.php" />
</rule>

<rule name="Rewrite to controller.php 2" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="^(developers.)" />
    <add input="{REQUEST_URI}" pattern="^/([_0-9a-z-]+)/([_0-9a-z-]+)/controller.php" />
  </conditions>
  <action type="Rewrite" url="\controller.php" />
</rule>

<rule name="Topics" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="^(developers.)" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <add input="{PATH_INFO}" pattern="^(/404|/js|/css|/img)+" negate="true" />
  </conditions>
  <action type="Rewrite" url="\index.php" />
</rule>

.htaccess file edit I figured out the http host

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(developers.)
RewriteRule ^/([_0-9a-z-]+)/controller.php /developers/controller.php

RewriteCond %{HTTP_HOST} ^(developers.)
RewriteRule ^/([_0-9a-z-]+)/([_0-9a-z-]+)/controller.php /developers/controller.php

RewriteCond %{HTTP_HOST} ^(developers.)
RewriteRule ^(/404|/js|/css|/img)+ /developers/index.php
RewriteEngine On
RewriteRule ^([_0-9a-z-]+)/controller.php /developers/controller.php
RewriteRule ^([_0-9a-z-]+)/([_0-9a-z-]+)/controller.php /developers/controller.php
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(/404|/js|/css|/img)+ /developers/index.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM