Forum Moderators: phranque
AliasMatch ^(/.+)$ /var/www/index.php$1
This works fine, but I now need to have the same effect from a RewriteRule in a .htaccess file (as I don't have access to the httpd.conf file on the new server).
I've had a rummage through the forums here (and delved through Google for a couple of hours) but not come up with a workable solution.
I basically need the following to happen:
1) User visits ht*p://www.doman.com/products/thing
2) Apache redirects (internally) to /index.php/products/thing
3) PHP then uses the PATH_INFO variable (which *should* contain /products/thing) to work out what to display
Any suggestions welcomed...
Welcome to WebmasterWorld [webmasterworld.com]!
That might be simple, or it might be hard, depending on mod_rewrite's behaviour with PATH_INFO - I'm not sure what it does with that variable during a rewrite.
All you need to do is rewrite the filename and try it to see if PATH_INFO is correct. The one thing you do need to be aware of is that the path available for matching in RewriteRule in an .htaccess context is different from the path in httpd.conf, in that the leading slash will be stripped off in .htaccess context.
So it's basically just
RewriteBase /var/www
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule (.*) /index.php/$1 [L]
Jim
So it's basically justRewriteBase /var/www
RewriteCond %{REQUEST_URI}!^/index\.php
RewriteRule (.*) /index.php/$1 [L]
Thanks for the above - it wasn't quite what was needed, but did point me in the right direction...
The above code wasn't putting the right value in PATH_INFO, but this one does:
RewriteRule (.+) /index.php%{REQUEST_URI} [L] It simply sticks the entire of the REQUEST_URI onto the end of the new destination (ie everything after the end of the domain).
Cheers, and thanks for the very quick response...
Steve
I'd be interested to know what the PATH_INFO was with each version, if you have time to post it.
Here's the relevant values given by my version (using the $_SERVER array from within PHP 4.3 under Apache/1.3.26):
[QUERY_STRING] =>
[REQUEST_URI] => /
[SCRIPT_NAME] => /index.php
[PATH_INFO] => /index
...and the original:
[QUERY_STRING] =>
[REQUEST_URI] => /
[SCRIPT_NAME] => /index.php
[PATH_INFO] => /
I've not changed anything other than in the .htaccess files to get the different result. Puzzling yes?
Steve