Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-04-21 17:43:16

Sam
Member
From: New York City
Registered: 2004-06-26
Posts: 127
Website

Redirect index.php but keep clean urls, possible?

Hi everyone,

For a current project I am working on I would like to redirect the very first page. So if you visit www.domain.com it get’s redirected to shop.domain.com (this will be powered by another system).

However, I would still like to be able to use Textpattern to power the other pages such as:

www.domain.com/about
www.domain.com/blog
www.domain.com/contact
etc.

How would this best be accomplished in your opinion? Thoughts, help and ideas are all appreciated.

Cheers,
-Sam

Offline

#2 2009-04-21 18:07:30

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: Redirect index.php but keep clean urls, possible?

Hi Sam, this might not give you what you want but one way would be not to redirect the fornt page but use something like

<txp:glx:if_frontpage>
<txp:php>include 'http://shop.domain.com/';</txp:php>
<txp:else />
whatever you want for the rest of the pages here...
</txp:glx:if_frontpage>

Last edited by colak (2009-04-21 18:11:11)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2009-04-21 18:23:11

Sam
Member
From: New York City
Registered: 2004-06-26
Posts: 127
Website

Re: Redirect index.php but keep clean urls, possible?

Hi Yiannis,

I don’t think that solution would work in this instance I really want people to be redirected, but perhaps using similar code I could meta refresh visitors to the sub-domain.

Thanks for posting, I appreciate all the help I can get figuring out the best solution on this one!

Last edited by Sam (2009-04-21 18:23:39)

Offline

#4 2009-04-21 18:42:22

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

Re: Redirect index.php but keep clean urls, possible?

We could try a little bit of mod_rewrite mumbo-jumbo, might help. Goes like this (give or take a few typos):

#DirectoryIndex index.php index.html

#Options +FollowSymLinks
#Options -Indexes

<IfModule mod_rewrite.c>
	RewriteEngine On
	#RewriteBase /relative/web/path/

	RewriteCond %{REQUEST_FILENAME} -f [OR]
	RewriteCond %{REQUEST_FILENAME} -d
	RewriteRule ^(.+) - [PT,L]

	# magic happens here, eventually
	RewriteCond %{REQUEST_URI} =/
	RewriteRule ^.* http://shop.example.com/ [L]

	RewriteCond %{REQUEST_URI} !=/favicon.ico
	RewriteRule ^(.*) index.php

	RewriteCond %{HTTP:Authorization}  !^$
	RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

#php_value register_globals 0

Usual disclaimer about the non-deterministic behaviour of mod_rewrite across Apache setups applies…

Last edited by wet (2009-04-21 18:53:05)

Offline

#5 2009-04-22 03:47:48

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: Redirect index.php but keep clean urls, possible?

Sam wrote:

I don’t think that solution would work in this instance I really want people to be redirected, but perhaps using similar code I could meta refresh visitors to the sub-domain.

Maybe this php solution will work

<txp:glx_if_frontpage> 
<txp:php>header( 'Location: http://shop.domain.com' ) ;</txp:php>
<txp:else />
other pages
</txp:if_frontpage>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2009-04-22 14:43:31

Sam
Member
From: New York City
Registered: 2004-06-26
Posts: 127
Website

Re: Redirect index.php but keep clean urls, possible?

Hey Robert, that method is what I had originally intended but couldn’t get to work.

I think Yiannis’ solution using a header redirect with PHP might be the best for me.

Thanks guys!

Offline

Board footer

Powered by FluxBB