Question

I am trying to redirect requests to my site from:

pbt.mysite.com/pbt/index.php?querystring....blahblahblah..

so I'd like to remove the /pbt/ segment of the url and keep the remaining query

to:

pbt.mysite.com/index.php?querystring....blahblahblah..

I've setup an IIS Rewrite rule with the following:

<rewrite>
        <rules>
            <rule name="Rewrite remove PBT segment from URL">
                <match url="^/pbt/([/_0-9a-z-]+)"/>
                <action type="Rewrite" url="{R:1}"/>
            </rule>
        </rules>
    </rewrite>

But this doesn't seem to work..

I'm wondering if there is a confusion in my rule because the subdomain is the same as the segment I want to remove (but keep the subdomain)

Additionally, this is a drupal site hosted in IIS so there may be a better way to do this in php (which I know nothing about)

Any ideas?

Was it helpful?

Solution

You have a leading slash that needs to be removed. Also, if you want to match on files and folders (not just folders as in your example), change the part between the parens too like so:

<match url="^pbt/(.*)$"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top