0

I have the following IIS URL Rewrite rules in web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="some-name" patternSyntax="Wildcard">
                    <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"/>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

They work for any subfolder, like this:

Case A

web.config and index.php are stored in folder1/test:
Request /folder1/test/some/virtual/12-url is sent to folder1/test/index.php.

Case B

web.config and index.php are stored in folder2/wherever/this:
Request /folder2/wherever/this/virtual/12-url is sent to folder2/wherever/this/index.php.

For switching to Apache, how can these rules be rewritten so that there is no need to update .htaccess whenever the subfolder URL changes? (The project may be hosted on any subfolder, does not require to be placed in Document Root.)

1 Answer 1

1

Try this

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d # not a dir
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^ index.php [L]
Sign up to request clarification or add additional context in comments.

1 Comment

Shows HTTP 500. Log: [core:alert] [pid 3580:tid 884] [client 127.0.0.1:56210] C:/thepath/.htaccess: RewriteCond: bad flag delimiters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.