Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-03-11 11:53:18

Hiram
Member
From: Utrecht, Netherlands
Registered: 2004-02-16
Posts: 35
Website

A conditional triggered by mod_rewritten pages

I moved one of my websites form static HTML to Textpattern/PHP. Now, visitors following search engine listings or bookmarks/favorites end up on the front page.

On the Textdrive forum, I posted a question regarding mod_rewrite. I want Google and other bots to understand that the old html pages are no longer there, so the redirect should happen with a 301 attached somehow. But that’s not all.

I’d like there to be a conditional piece of text on the front page, to be displayed iff the visitor was redirected by the mod_rewrite. It should say something like: This is not the page you were looking for. It’s the front page. All pages on this website have moved, that’s why. Please use the search box to find what you came here for.

Ideally, the search box would be displayed only as part of the conditional text. Not on the regular index.php page, that is.

Can this be done? Any help will be greatly appreciated.

Last edited by Hiram (2006-03-11 12:00:49)

Offline

#2 2006-03-11 18:10:31

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: A conditional triggered by mod_rewritten pages

Your link to the Textdrive forum says ‘bad request’. I don’t know if whatever is in there is important to understand your question.

I’m assuming that you are redirecting requests for html pages to your new homepage. I don’t know about a conditional, that would have to be something like if_referrer. I remember searching for that a while ago but didn’t find anything.
As an alternative you could redirect those requests not to the homepage, but to a page you create especially for this, in it’s own section.

Offline

#3 2006-03-11 18:44:28

Hiram
Member
From: Utrecht, Netherlands
Registered: 2004-02-16
Posts: 35
Website

Re: A conditional triggered by mod_rewritten pages

Els wrote:

Your link to the Textdrive forum says ‘bad request’. I don’t know if whatever is in there is important to understand your question.

The link works here. But your answer is quite sufficient as it is; thank you.

I’m assuming that you are redirecting requests for html pages to your new homepage. I don’t know about a conditional, that would have to be something like if_referrer. I remember searching for that a while ago but didn’t find anything.

Then I guess I’m out of luck, in this.

As an alternative you could redirect those requests not to the homepage, but to a page you create especially for this, in it’s own section.

And that’s what I’ll do.

Offline

#4 2006-03-12 09:03:16

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

Re: A conditional triggered by mod_rewritten pages

Do your new pages share some URL elements with the old ones, i.e. did you convert them following a certain pattern?

Then you can use Apache’s RedirectMatch directive, which is like permanent redirects with regular expressions. I’m not familiar with it in detail but if you can figure out the RegExs, that should probable do the trick.

Offline

#5 2006-03-13 07:30:20

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

Re: A conditional triggered by mod_rewritten pages

I am no expert but a simple way would be to create some basic rules in htaccess
ie
<code>ErrorDocument 404 http://www.yoursite.com/errors/404.html
ErrorDocument 301 http://www.yoursite.com/errors/301.html</code>

then in the html documents have something for the search engines ie
<code><meta name=“robots” content=“noindex,follow” /></code>

and in their body of the html documents have links to your main dynamic page.


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

Offline

Board footer

Powered by FluxBB