Forum Moderators: phranque
RewriteRule ^fake-dir-name/(.*)\.html$ fake-dir-name.php?x=$1 [T=application/x-httpd-php]
The link is in the form of h**p://www.domain.com/dir/fake-dir-name/var.html
The file fake-dir-name.php is under the directory /dir/ as the URL indicates.
I've been banging my head against the wall for the past hour and can't see the error. If I manually pass the var on the URL it works great. A test for 'x' shows it isn't being set.
I've used this exact code only without trying to include a fake sub directory and it works great. What did I miss/mess up?
This is just a regular-expressions issue. Take the start anchor (^) off the pattern in your RewriteRule. Or alternatively, specify the full path to the resource in the pattern and use the start anchor (this will restrict the rule to operating only for that specific directory/subdirectory path, though).
So, either
RewriteRule [b]f[/b]ake-dir-name/(.*)\.html$ fake-dir-name.php?x=$1 [T=application/x-httpd-php]
- or -
RewriteRule [b]^dir/f[/b]ake-dir-name/(.*)\.html$ fake-dir-name.php?x=$1 [T=application/x-httpd-php]
Jim
Well I got it to work but the URL was horrible. All of the files for this scheme are in /dir/. SO in order to get it to work I had to use the relative path /dir/fake-dir-name/var.html.
The regex for the rewrite rule was dir/fake-dir-name/(.*)\.html$ The URL comes out as h**p://www.domain.com/dir/dir/fake-dir-name/var.html
So I figured all I needed to do was to drop the /dir/ from the link and the regex. Nada
I know I'm close.