I have the below VirtualHost and HTML. The purpose of the VirtualHost is to take http://example.com/bla/index.php?id=3 and rewrite it as http://example.com/index.php?admin=bla&id=3. If the URL in the browser is http://example.com/bla/, both the form and the links go to http://example.com/bla/index.php. But if I put http://example.com/bla (without the trailing forward slash) in the browser, the posts go to http://example.com/bla/index.php, but the the links go to http://example.com/index.php (without the "bla"). Why is this, and what do I do to direct the links to http://example.com/bla/index.php?
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html
<Directory "/var/www/html">
allow from all
Options +Indexes
RewriteEngine On
RewriteBase /
# If the request is for a valid directory, file, or link, don't do anything
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]
RewriteRule ^([^/]*|[^/]+/(index.php)?)$ /index.php?admin=$1 [L,QSA]
</Directory>
</VirtualHost>
index.php
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Links</title>
</head>
<body>
<a href="index.php?id=1">link 1</a>
<a href="index.php?id=2">link 2</a>
<a href="index.php?id=3">link 3</a>
<form method="post">
<input type="text" name="post_text">
<input type="submit" value="submit">
</form>
</body>
</html>