Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-03-04 14:53:17

joel
Member
Registered: 2004-11-26
Posts: 162

htaccess for maintenance

Hey everyone,

I’m working live on a site and I would like to serve the visitors that browse to www.domain.com an index.html with some temporary information. At the same time I need to have the clean URL’s in function for the sections I’m developing… The sections can easily be protected by password. The main thing is to get the visitors a temp-page during the development process.

All help is appreciated! :)

Offline

#2 2007-03-04 15:13:24

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: htaccess for maintenance

Set a negative condition: if anyone not having your IP, he will be redirected (temporarily) to /workingonit or whatever.

No?

Something like:

RewriteCond %{REMOTE_ADDR}  !^123\.45\.67\.98$
RewriteRule ^.*$ /workingonit [R=302,L]
your TXP rewrites rules here

I’m not sure about the syntax, Apache and I have an understanding: it won’t function logically or consistently around me… ever.

Last edited by Jeremie (2007-03-04 15:24:29)

Offline

#3 2007-03-04 16:08:37

joel
Member
Registered: 2004-11-26
Posts: 162

Re: htaccess for maintenance

Thanks for the suggestion.

I guess I was thinking more like a hiearcial rule like .htm, .html, .php etc.

and of course the regular txp rewriting-rules below it.

An IP-check would make it troublesome for me since I have dynamic IP. And the client also need the ability to check it out once in a while.

Is this possible in an easy way?

Thanks again

Offline

#4 2007-03-04 16:21:42

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: htaccess for maintenance

I used this, so I could visit test.example.com to test my website, while visitors to www.example.com and example.com would see the index.html page with launching.png graphic:

<IfModule mod_rewrite.c>
 RewriteEngine On

 # redirect to entry page unless testing domain is used
 RewriteCond %{HTTP_HOST} !^test.example.com$
 RewriteCond %{REQUEST_URI} !^\/index.html$
 RewriteCond %{REQUEST_URI} !^\/launching.png$
 RewriteRule ^(.*) index.html [L]

 # force trailing slashes (avoid redirect to example.com)
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^(.+[^/])$ http://test.example.com/$1/ [R,L]

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

 RewriteRule ^(.*) index.php
</IfModule>

It does require you to change the Site URL in the TXP preferences from example.com to test.example.com, but that’s easy to revert just before going live again.

This also assumes that test.example.com is an alias for example.com. If you can’t add such aliases easily, you can use an already existing alias as well, like mail.example.com or ftp.example.com.

Last edited by ruud (2007-03-04 16:27:52)

Offline

#5 2007-03-04 16:36:18

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: htaccess for maintenance

This also require virtual server access ruud, and some dns entries. It won’t work on some shared servers.

Offline

#6 2007-03-04 16:39:39

joel
Member
Registered: 2004-11-26
Posts: 162

Re: htaccess for maintenance

thanks for the answer. This however isn’t working on my clients web host.

Offline

#7 2007-03-04 21:31:50

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: htaccess for maintenance

If you use an exotic UA, you can try a set of rules. Like your IP range, plus your exact UA, things like that. Not fully secure, but it will catch 99.9999% of the visits.

Offline

#8 2007-03-04 22:30:42

joel
Member
Registered: 2004-11-26
Posts: 162

Re: htaccess for maintenance

Sounds interesting…
Can you please give me an example?

Offline

#9 2007-03-04 22:51:36

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: htaccess for maintenance

Using a user agent switcher in Firefox (if you happen to use that, though some other browsers support this as well), you can set your own unique user agent and use that to test on in .htaccess

RewriteCond %{HTTP_USER_AGENT}  !^your unique user agent$
RewriteRule ^.*$ /workingonit [R=302,L]
your TXP rewrites rules here

Offline

#10 2007-03-05 00:45:59

joel
Member
Registered: 2004-11-26
Posts: 162

Re: htaccess for maintenance

That sounds pretty cool, but I work in Safari, FF and IE 6 & 7 to achieve full browser compability during the development process.

Offline

#11 2007-03-05 01:11:45

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: htaccess for maintenance

Let’s try another shot. The Apache doc on mod_rewrite says RewriteCond accept HTTP_COOKIE as a variable. It doesn’t explain it further, but I’m guessing that you could set up a unique, specific cookie on your computers, and check against that.

No idea on how secure/unsecure that would be, and how do it exactly; you’ll have to dig through the Apache manual.

Last edited by Jeremie (2007-03-05 01:12:23)

Offline

#12 2007-03-05 08:01:36

joel
Member
Registered: 2004-11-26
Posts: 162

Re: htaccess for maintenance

But all I need is a rule that serves a static index.html for everyone who doesn’t know about my clean Url sections. I can always password-protect my sections.

For now, I have the index.html working beside textpattern. The only downside is that I’m stuck with messy url’s since I’m not using a htaccess.
How can I get clean url’s working and still keep my index.html for those who doesn’t know about my other sections?

Offline

Board footer

Powered by FluxBB