1

I looked around for an answer, but I could not find one that would work for me.

I have this:

RewriteRule ^(.*)/?$ example.php?option=$1 [L]

What I want is this:

http://example.com/foo/bar/ > http://example.com/example.php?option=foo/bar
http://example.com/foo/bar  > http://example.com/example.php?option=foo/bar

But what is happening is this:

http://example.com/foo/bar/ > http://example.com/example.php?option=foo/bar/
http://example.com/foo/bar  > http://example.com/example.php?option=foo/bar

So, when there is a trailing slash, it adds it to the option it sends to the PHP file, but I don't want it to remove it. Any ideas?

Colton DRG
  • 17
  • 3
  • [This answer](http://stackoverflow.com/a/8744956/3770448) is possibly of interest. – ljacqu Jul 20 '14 at 06:18
  • @ljacqu Nope. Because of the nature of my website, I cannot do a redirect or it will loop. I did find a way to make it work within the PHP file though. – Colton DRG Jul 20 '14 at 06:26

1 Answers1

0

I actually found a way to get this done! In the example.php I added this:

$option = $_GET['option'];
$option = rtrim($option, '/');

This removes all trailing slashes from the option string, but it does not remove the slashes in the middle. Just what I needed.

If anyone finds a way to do this in the RewriteRule, please post because it might be useful if anyone needs to do this in a non-php context.

Colton DRG
  • 17
  • 3