简体   繁体   中英

Convert web.config file to .htaccess PHP

Can anybody help me to convert this web.config file to .htaccess.

I'm trying to search on google but unable to find the desired result.

Here is my webconfig.

<rules>
    <rule name="HTTP api" stopProcessing="true">
        <match url="^(.*/)?api/(.*)$" ignoreCase="true"/>
        <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile"
                ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory"
                ignoreCase="false" negate="true" />
        </conditions>
        <action type="Rewrite" url="{R:1}api/http.php/{R:2}"/>
    </rule>
    <rule name="Site pages" stopProcessing="true">
        <match url="^(.*/)?pages/(.*)$" ignoreCase="true"/>
        <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile"
                ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory"
                ignoreCase="false" negate="true" />
        </conditions>
        <action type="Rewrite" url="{R:1}pages/index.php/{R:2}"/>
    </rule>
    <rule name="Staff applications" stopProcessing="true">
        <match url="^(.*/)?scp/apps/(.*)$" ignoreCase="true"/>
        <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile"
                ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory"
                ignoreCase="false" negate="true" />
        </conditions>
        <action type="Rewrite" url="{R:1}scp/apps/dispatcher.php/{R:2}"/>
    </rule>
</rules>

Try:

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule "^(.*/)?api/(.*)$" $1api/http.php/$2 [NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule "^(.*/)?pages/(.*)$" $1pages/index.php/$2 [NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule "^(.*/)?scp/apps/(.*)$" $1scp/apps/dispatcher.php/$2 [NC]

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