I am trying to rewrite a URL using .htaccess. I am running on Apache version 2.2.15.
Contents of .htaccess:
RewriteEngine on
RewriteRule cars/(.*) cars/member_page.php?user=$1
RewriteRule cars/(.*)/ cars/member_page.php?user=$1
Contents of member_page.php:
<?php
echo $_GET[user];
?>
URL entered into browser:
http://www.mydomain.com/cars/user1
The browser outputs the string “member_page.php” instead of “user1”
How do I make it output the contents of (.*) from the original URL.
The problem with this format:
Turns out that I was rewriting cars/whatever to cars/member_page.php. This creates the problem of rewriting to the same directory that the rewrite is on.
So
was rewritten to
It was rewritten twice using the content from the second rewrite as the final information. The solution is to move member_page.php to a different directory.