views:

139

answers:

1

I've created a symlink in an account to an folder external to that user account (although with the same ownership). The symlink works but I'd like to combine it with a RewriteRule, and I'm having problems with that.

For instance I create the symlink with:

ln -s /home/target shortcut

And I add the following RewriteRule to .htaccess:

RewriteRule ^shortcut/([a-zA-Z0-9_-]+) shortcut/index.php?var=$1

This however fails.

Yet if instead of being located in an external folder, the target folder is in the same folder as the shortcut address, then the RewriteRule will work. i.e. it works if the symlink is:

ln -s ./target shortcut

How might I get the RewriteRule working for the case where the target folder is an external folder?

+1  A: 

The problem might be that [a-zA-Z0-9_-]+ will also match the index in index.php. So you’re getting an infinite loop. Try this instead:

RewriteRule ^shortcut/([a-zA-Z0-9_-]+)$ shortcut/index.php?var=$1
Gumbo
Thanks, although I've also attempted this without the regex - e.g. RewriteRule ^shortcut/value shortcut/index.php?var=valueAlso just tried RewriteRule ^shortcut/value$ shortcut/index.php?var=valueAs well as the variation you gave. None of these works.
Tristan