<p>I've the following rewrite rule in .htaccess:</p>

<pre><code>RewriteRule ^groups/([^/\.]+)/?$  groupdetail.php?gname=$1 [L,NC]
</code></pre>

<p>This takes something like www.example.com/groups/groupname and calls www.example/groupdetail.php?gname=groupname.  And it works just fine.</p>

<p>But all the relative links on groupdetail.php use groups/ as the relative path, and I don't want them to.  How do I avoid this?</p>

<p>For example, when a user clicks on a link <code>&lt;a href="link.php"&gt;</code> on groupdetail.php?gname=groupname, he's taken to www.example/groups/link.php.  I want to take the user to www.example.com/link.php.</p>

<p>Obviously, I want to URL to the user to look like "www.example.com/groups/groupname" so I  don't want to use [R]/redirect.</p>

If you change the rewite rule to do a
force redirect
(add the [R] option), then the browser will be using the /groupdetail.php URL and the relative links will work fine.  However, that adds one redirect and makes the URLs less pretty.
```
```
RewriteRule ^groups/([^/.]+)/?$ groupdetail.php?gname=$1 [L,NC,R]
```
```