| 7:11 pm on Mar 25, 2013 (gmt 0)|
Wow - all morning I've been messing with this - just figured it out. My rewrites work - the problem is that the url is depositing itself into a frame. I just tried with the main url - works great.
| 9:48 pm on Mar 25, 2013 (gmt 0)|
I am avidly awaiting a follow-up post, because frankly I don't see how the rule can work-- frame or no frame. The query string isn't visible to mod_rewrite unless you put it in a RewriteCond.
| 9:54 pm on Mar 25, 2013 (gmt 0)|
no conditions for any of the rules - this is what I ended up using
RewriteRule ^jump.php?dbID=(.*)&ban_www=/company-detail.php?com_id=(.*)$ company-detail.php?com_id=$2 [R=301,L,QSA]
| 10:09 pm on Mar 25, 2013 (gmt 0)|
Never use (.*) at the beginning or in the middle of a RegEx pattern.
(.*) means "match everything remaining" - that means everything to the end, i.e. there will be nothing after it.
Be aware that a rewrite takes an incoming URL request and "rewrites" Apaches internal pointer to point to a specific folder and file in the internal filesystem. Rewrites are internal to the server.
A rewrite does not affect URLs in any way whatsoever. URLs are used out there on the web and have no meaning inside the server.
On the other hand, a redirect tells the requester to make a new request for a different URL. But again it doesn't "change" a URL, it merely tells you to request a different one.
In your original question, you asked for a "rewrite" but the code in your last post is for a "redirect".
Whatever you want, the rule you posted can never work. The RegEx pattern in a RewriteRule can match only the path part of the URL request. It cannot ever match requested query strings. Those are matched using a preceding RewriteCond looking at either QUERY_STRING or THE_REQUEST.
If you want a redirect, the rule target should include protocol and hostname.
A redirect maps a URL to a new URL.
A rewrite maps a URL to an internal filepath.
Be sure you know what you want. Redirects and rewrites are both coded using RewriteRules with only minor differences in syntax.
| 10:22 pm on Mar 25, 2013 (gmt 0)|
My apologies for using the incorrect form (redirect/rewrite) I think a rewrite is what I was looking for.
I'm open to suggestions on cleaning that up, the rule however does function, and do exactly what I was looking for, but it is pretty messy. (I'm happy to pm you a link)
Are you saying that I could get rid of everything after the first (.*)? Some of the old references to jump.php have different requests, (company-detail, job detail, etc), just trying to clean up references to a bunch of junk that was removed, but retain function for any sites that may be linking.
| 10:33 pm on Mar 25, 2013 (gmt 0)|
er... redirect.. still doing it :(
| 12:16 am on Mar 26, 2013 (gmt 0)|
welcome to WebmasterWorld, racerx8413!
what is "it" "doing"?
- post your current code
- describe what you requested
- describe what you expected
- describe the actual response
as mention by lucy24 and g1smd, everything starting from the '?' will fail the condition in the pattern, since this is not part of the path and the pattern in the RewriteRule only matches the path, not the query string.
| 1:29 am on Mar 26, 2013 (gmt 0)|
...and even when you do look at the query string:
:: pause to count on fingers ::
I make that two ? question marks ? in the URL, which is one more than your average php script is prepared to deal with. Is the second one a literal question mark within the "ban_www" parameter so you've got nested queries and you need to un-nest them?
| 11:18 am on Mar 26, 2013 (gmt 0)|
|I make that two ? question marks ? in the URL, which is one more than your average php script is prepared to deal with. Is the second one a literal question mark within the "ban_www" parameter so you've got nested queries and you need to un-nest them? |
actually the "2nd url", which is a parameter value within the query string, contains reserved characters which must be percent-encoded in the requested url such as in the (assuming HTML) href attribute value.
|Many URL schemes reserve certain characters for a special meaning: their appearance in the scheme-specific part of the URL has a designated semantics. |
If the character corresponding to an octet is reserved in a scheme, the octet must be encoded.
The characters ";", "/", "?", ":", "@", "=" and "&" are the characters which may be reserved for special meaning within a scheme.
the TestString regex in your RewriteCond will have to look for the percent-encoded reserved characters within the QUERY_STRING.