g1smd

msg:4146461 | 6:45 pm on Jun 3, 2010 (gmt 0) |
What is it meant to to do? RewriteRule can only see the path part of the URL. You will therefore need a preceding RewriteCond looking at QUERY_STRING. The redirect target should include the protocol and domain name.
|
beachlover

msg:4146568 | 8:50 pm on Jun 3, 2010 (gmt 0) |
Damn, I knew I was way off here. So thanks for your heads up. I guess this will work then: Options +FollowSymLinks RewriteEngine On RewriteCond %{QUERY_STRING} ^section=(oldpage*)$ RewriteRule main.php ht tp://www.domain.com/newpage/ [L,R=301]
|
jdMorgan

msg:4146591 | 9:14 pm on Jun 3, 2010 (gmt 0) |
The rule as written will 'carry forward' the originally-requested query string. Is that what you want to do? Again, what exactly is this rule meant to do? What is the (full) requested URI-path to be redirected, and what is the full URI to be redirected to? "It will work" is only about 10% of the way to "It will work properly with no unintended side effects," and that is not good enough; For optimal results, nail down your requirements firmly before we start coding. Jim
|
beachlover

msg:4146621 | 9:42 pm on Jun 3, 2010 (gmt 0) |
Thanks for your response. Basically I want to redirect the old php-file to a new file (which is now in a directory-based CMS): ht tp://domain.com/main.php?section=oldpage to ht tp://domain.com/newpage/
|
jdMorgan

msg:4146636 | 10:01 pm on Jun 3, 2010 (gmt 0) |
In that case, you "bascially" need to clear the query string using the "?" operator on the substitution URL:
Options +FollowSymLinks RewriteEngine On # RewriteCond %{QUERY_STRING} ^section=oldpage-string$ RewriteRule ^main\.php$ http://www.example.com/newpage/? [L,R=301]
Note othe minor corrections to literal query string value, anchoring, and literal-character escaping in rule pattern. You can use the mod_rewrite documentation at apache.org to determine if this is exactly what you want to do. Jim
|
beachlover

msg:4146640 | 10:07 pm on Jun 3, 2010 (gmt 0) |
Thanks Jim, works like a charm.
|
g1smd

msg:4146657 | 10:47 pm on Jun 3, 2010 (gmt 0) |
What happens if you ask for the non-www version of the old URL, and/or if you append extra parameters? Does it then still do exactly what you want?
|
|