Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Redirects same site

Posted by TedH (TedH), 10 August 2007
Hi Graham, trust you're well.

Not sure what to use here.

I think I need to use a 302 redirect.

Server: Apache Web Server 1.3

Object is to redirect, temporarily, all the pages in my /public_html directory to a single page in the same directory. This is for updating an entire site. When done the .htaccess will be removed.

Is this possible?
Code:
Redirect / http://www.mydomain.com/tempage.html



Or to another directory:
Code:
Redirect / http://www.mydomain.com/tempage/tempage.html

?

I know I can use .htaccess for this by listing each page, just wondered if there was an easier way.

Hope you can help,
thanks - Ted


Posted by admin (Graham Ellis), 11 August 2007
Personally I would use mod_rewrite, as this ensures that page is served in a single request and the name is preserved.   Could make a difference in search engine placements

Something like ...

RewriteEngine On
Rewrite *.html tempname.html

... in your .htaccess, but I am away at the moment and have writen that from memory

Posted by TedH (TedH), 11 August 2007
I'll check that out, thanks Graham

Posted by TedH (TedH), 11 August 2007
Graham, got it sorted (w/help from my tech suppt and server forum as well). Thought you'd like to see the solution.

Code:
<IfModule mod_rewrite.c>
RewriteEngine on
Rewritecond %{REQUEST_URI} !(^/update\.html$) [NC]
RewriteRule (.*) /update\.html [R=302,L]
</IfModule>


By having an "update page" in the web folder, an .htaccess with the above code in will redirect to that page. This happens with all sub-directories as well.

This works on my live server, but am not sure if it will work on all Apache servers (?) - I don't know if this sort of stuff is like Perl (101 ways to do the same thing).

Cheers - Ted

Posted by admin (Graham Ellis), 12 August 2007
The two things this depends on are
(1) Is mod_rewrite loaded and
(2) Does the main httpd.conf file allow for .htaccess overrides.

Posted by TedH (TedH), 14 August 2007
Thanks Graham, trust you got back okay (easily)  

Posted by admin (Graham Ellis), 14 August 2007
Still away, Ted ... posting from New York state!



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho