Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-09-22 23:31:28

sthmtc
Member
From: CGN, GER
Registered: 2005-01-17
Posts: 586
Website

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 to

http://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

#2 2008-09-22 23:46:06

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: remove '?pg=1' from the url with mod_rewrite?

You could put this in your template
<txp:php>unset($_GET['pg']);</txp:php>


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#3 2008-09-23 00:06:18

sthmtc
Member
From: CGN, GER
Registered: 2005-01-17
Posts: 586
Website

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

#4 2008-09-23 00:14:49

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: remove '?pg=1' from the url with mod_rewrite?

<txp:php>
if(gps('pg') == 1 && section(array()) == 'default') header('Location: '.hu , TRUE , 301);
</txp:php>

Offline

#5 2008-09-23 00:21:02

sthmtc
Member
From: CGN, GER
Registered: 2005-01-17
Posts: 586
Website

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

#6 2008-09-23 00:37:21

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

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

#7 2008-09-23 00:39:41

sthmtc
Member
From: CGN, GER
Registered: 2005-01-17
Posts: 586
Website

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

#8 2008-09-23 00:41:52

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: remove '?pg=1' from the url with mod_rewrite?

Sorry i misunderstood your requirements.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#9 2008-09-23 06:28:35

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

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

Board footer

Powered by FluxBB