Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#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
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
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
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
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
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
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