Hello, I have a quick question. How can I pass a variable from my PHP script to my htaccess? For example, I have a variable called $testVar. I've set $testVar = "Content". How can I use a mod_rewrite rule to do something like this? I've seen this everywhere, and I've gotten it working, but I need something more. "Instead of page.php?id=4, put page/4.htm" Instead of page/4.htm, I want to make it page/$testVar.htm, or page/Content.htm. Is that possible? And how? Thanks
I think you mean from your htaccess to php. If so, you would use mod rewrite. For example, this rule takes a condition of a user going to a certain domain and then passing it as a variable RewriteCond %{HOST} <somedomain> RewriteRule ^(.*) http://myhost/bin/index.php?domain=$1 [P,L]
Simple answer, no. By the time PHP knows about the request, the mod_rewrite fules in htaccess have already been processed. You'll have to forget about mod_rewrite/htaccess and use the "header()" function in PHP to send a "Location" header in addition to a 301/302 HTTP status code.