Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
Sam Brown
sambrown.me | welovetxp.com
Offline
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
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)
Sam Brown
sambrown.me | welovetxp.com
Offline
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
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
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!
Sam Brown
sambrown.me | welovetxp.com
Offline