<p>I have this rewrite rule</p>

<pre><code>RewriteEngine On
RewriteBase /location/
RewriteRule ^(.+)/?$ index.php?franchise=$1
</code></pre>

<p>Which is suppose to change this URL</p>

<pre><code>http://example.com/location/kings-lynn
</code></pre>

<p>Into this one</p>

<pre><code>http://example.com/location/index.php?franchise=kings-lynn
</code></pre>

<p>But instead I am getting this</p>

<pre><code>http://example.com/location/index.php?franchise=index.php
</code></pre>

<p>Also, adding a railing slash breaks it. I get index.php page showing but none of the style sheets or javascript are loading.</p>

<p>I'm clearly doing something very wrong but I have no idea what despite spending all day R'ingTFM and many online primers and tutorials and questions on here. </p>

Your problem is you are redirecting twice.
```
'location/index.php'
```
matches the regex
```
^(.+)/?$
```
You want to possibly use the "if file does not exist" conditional to make it not try mapping a second time.
```
```
RewriteEngine on
RewriteBase /location/
RewriteCond %{REQUEST_FILENAME} !-f   # ignore existing files
RewriteCond %{REQUEST_FILENAME} !-d   # ignore existing directories
RewriteRule ^(.+)/?$ index.php?franchise=$1  [L,QSA]
```
```
And additonally, theres the [L,QSA] which tries to make it the "last" rule ( Note, this is not entirely obvious how it works ) and append the query string to the query, so that
```
```
location/foobar/?baz=quux  ==> index.php?franchise=$1&baz=quux
```
```
( i think )