Forum Moderators: phranque
/page.html?p=end
to
/index.html
After spending a few hours browsing the messages here, reading up on regular expressions and so on, I was finally able to come up with what I required:
rewriteCond %{query_string} p=end
rewriteRule ^page.html$ /index.html? [R,L]
It works, but I'm still thinking what I did may be dodgy - that is, there might be a better way? Something I did have trouble with was it would attach the query string (?p=end) to index.html - however I placed a '?' at the end and that got rid of it. :)
Are there any better ways of doing the redirect from a query string to another page without the query string being attached?
Thanks,
Kurieuo.
Your solution looks OK to me!
You may want to escape the period in the "page.html" pattern, since otherwise, it means "any character."
RewriteRule ^page\.html$ /index.html? [R,L]
RewriteRule ^page\.html$ /index.html? [L]
i'm very interested in this discussion because i am half way through developing a cgi script for a large directory and i want the site to look as if it is totally static html.
is it possible to use static looking urls e.g. www.a.com/widget/red.html , rewrite them to www.a.com/cgi-bin/my.cgi?product=widget&color=red, then dynamically generate the html but leaving www.a.com/widget/red.html in the browser bar? ie the entire site looks static in the browser address bar and also in all of the links on each web page?
the first possibilty
RewriteRule ^page\.html$ /index.html? [R,L]
RewriteRule ^page\.html$ /index.html? [L]
Where should I implement the kind of redirect, i.e. 301 or whatever? Should it be in the brackets, too?
(Of course, only in the first solution: [R=301,L] - correct?)
So the first RewriteRule [httpd.apache.org] does an external redirect while the second rule will just do an internal rewrite.