lucy24

msg:4541135 | 11:37 pm on Jan 31, 2013 (gmt 0) |
Woo hoo, an easy one. Neither of your rules is a redirect. They are both rewrites: User thinks they are at point A, while your server is secretly serving up content from B. In order for the URL (the contents of the address bar) to change, you have to redirect: RewriteRule {input here} http://www.example.com/{output here} [R=301,L] Full protocol and domain name AND R=301 flag. AND keep the [L]. (This is counter-intuitive but essential.)
|
g1smd

msg:4541158 | 1:04 am on Feb 1, 2013 (gmt 0) |
In addition to both of your rules being rewrites when you need to alter the first one to be a redirect (still using RewriteRule syntax of course), the other reason the first rule doesn't work is that your pattern is trying to match path and parameters. RewriteRule patterns can match only the path part of the URL request. You need a preceding RewriteCond that looks at the QUERY_STRING or in this case at THE_REQUEST to be sure that the user requested a URL with an appended query string. Don't forget to escape the literal period in the RegEx pattern. Use example.com in this forum to supress URL auto-linking.
|
nestman

msg:4541163 | 1:41 am on Feb 1, 2013 (gmt 0) |
Am I getting closer? # Most Recent postings RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^example.php?t=1 http://www.example.com/recent [R=301,L] RewriteRule ^example.php?t=1$ recent [L]
|
lucy24

msg:4541174 | 3:11 am on Feb 1, 2013 (gmt 0) |
Further away, I think. What has the HTTP_HOST got to do with anything? Unless you have subdomains, you should have only one rule that looks at the HTTP_HOST -- and this isn't it. You missed the part of g1's post where he explained that mod_rewrite can't see parameters. In the body of a Rule,
example.php?t=1 will be interpreted as "www.example.com/example{any single character}ph{optional p}t=1" I do not think you will get many requests for this filename. | You need a preceding RewriteCond that looks at the QUERY_STRING or in this case at THE_REQUEST |
| The line for THE_REQUEST is because you only want to redirect people who explicitly asked for the long ugly form of the name-- not people who asked for the short pretty form and have been secretly rewritten to the longer uglier form. Here [webmasterworld.com] is one version of the boilerplate. Third post (second reply) in thread, the part in the "quote" block.
|
|