Forum Moderators: phranque
RewriteRule /([^-]+)-1\.php /brands/brand.php?manu=$1
In making a request to the following URL:
http://www.mydomain.com/MyBrand-1.php
... and doing:
$parray = explode("/", $REQUEST_URI);
echo ($parray[1]);
It prints this to output:
MyBrand-1.php
This is fine, however, if I want to add a new name-value pair to the request, I get strange results... ie:
http://www.mydomain.com/MyBrand-1.php?test=123456
... the resulting page prints out (via the PHP function above):
MyBrand-1.php?test=123456
So, I tried modifying the RewriteRule so it could accept another parameter... ie:
RewriteRule /([^-]+)-1\.php?test=([^0-9]+]) /brands/brand.php?manu=$1&test=$2
... and other variations, but, I can never get the "test" variable passed over to my script correctly. I always end up with:
MyBrand-1.php?test=123456 ... after parsing out the REQUEST_URI in PHP.
I was thinking it would be a lot easier to just pass another parameter along to the next page... but am having a very hard time. Any help would be appreciated!
Example link. www.yourdn.com/file.php?v=3455&x=bubba
Convert links to www.yourdn.com/3455/bubba/file.php
Then use mod-rewrite to parse the URL into the vars and pass them to the file.
learn more [webmasterworld.com]
what's wrong with my current setup?
i'm currently using a hyphen as my delimitation like so:
RewriteRule /([^-]+)-1\.php /brands/brand.php?manu=$1
it is working perfectly, as a request to:
/product-1.php sends me to:
/brand.php?manu=product
...but can't figure out how to pass another parameter to the brand.php page.
for example, if this URL was requested:
/product-1.php?test=123456
... it would actually request the /brand.php page with the "test" variable as well as the "manu" variable.
i'm trying to avoid using a directory schema (ie: test/var/var2), and am trying to use a hyphen delimited schema.
Perhaps jdMorgan will stop by and set you straight on the method you started with.
Many, many thanks!
RewriteCond %{QUERY_STRING} ^pagin=([^&]*)$
RewriteRule /([^-]+)-1\.php /brands/brand.php?keyword=bags&manu=$1&pagin=%1
using the above writeCond/Rule, the "pagin" parameter is passed through correctly, but the "manu" paramter is not.
is the substitution in the RewriteRule ($1) ignored and only the RewriteCond processed... or, is there a problem with the above condition?
RewriteRule /([^-]+)-1\.php(\?pagin=[0-9]+)* /brands/brand2.php?manu=$1&pagin=$2
In requesting:
/product-1.php?pagin=123456
The "pagin" value doesn't exist on the resulting page (the "manu" parameter is populated perfectly). I've read the Apache doc over and over again, and don't see anything wrong with the above.
Pleeeeeease elighten me!
:D
It's no good looking to match a query string using RewriteRule - it won't work.
If you could explain what you are trying to do from end-to-end, including the original requested URL-path with query string, the desired output of mod_rewrite, and your overall goal, that would probably help get a better answer. When redirecting to scripts, many things can go wrong -- and often do. A good definition of the problem is needed.
Also, will your rewrite have to deal with missing query parameters, or with the parameters in a different order?
Jim