Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
remove '?pg=1' from the url with mod_rewrite?
sorry to sound so n00bish but i think i need your help here:
for reasons that are a bit complicated to explain and not relevant after all, i want to rewrite all requests tohttp://www.mydomain.com/?pg=1
to
http://www.mydomain.com/
(should only happen for ?pg=1 — not for ?pg=2, etc)
tried a ton of different things but i’m either getting an error 500 or it doesn’t work. grrrr. guess this is a no brainer for someone who knows what he’s doing, right? :)
Last edited by sthmtc (2008-09-23 00:32:07)
Offline
Re: remove '?pg=1' from the url with mod_rewrite?
You could put this in your template
<txp:php>unset($_GET['pg']);</txp:php>
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: remove '?pg=1' from the url with mod_rewrite?
thanks matt but as i said above:
“(should only happen for ?pg=1 — not for ?pg=2, etc)”
Offline
Offline
Re: remove '?pg=1' from the url with mod_rewrite?
thanks gocom! so is this the best way? i thought that mod_rewrite would be the right tool for the job…
EDIT: aargh. i was having the same issue before. when doing a redirect like this i’m getting:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>200 OK</TITLE>
</HEAD><BODY>
<H1>OK</H1>
The document has moved <A HREF="http://www.mydomain.com/">here</A>.<P>
<HR>
<ADDRESS>Apache/1.3 Server at www.mydomain.com Port 80</ADDRESS>
</BODY></HTML>
Last edited by sthmtc (2008-09-23 00:24:11)
Offline
Re: remove '?pg=1' from the url with mod_rewrite?
Try this:
<txp:php>
if(gps('pg') == 1 && section(array()) == 'default')
{
if (IS_CGI)
{
txp_status_header('303 See Other');
}
header('Location: '.hu , TRUE , 301);
}
</txp:php>
Offline
Re: remove '?pg=1' from the url with mod_rewrite?
that worked! thanks jon-michael.
(however, i’m still a bit confused why nobody is suggesting a mod_rewrite solution ;))
Offline
Re: remove '?pg=1' from the url with mod_rewrite?
Sorry i misunderstood your requirements.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: remove '?pg=1' from the url with mod_rewrite?
sthmtc wrote:
(however, i’m still a bit confused why nobody is suggesting a mod_rewrite solution ;))
Thou shalt not stay in confusion any longer:
RewriteCond %{QUERY_STRING} pg=1 [NC]
RewriteRule .* / [L]
Offline