SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    .* draziW tnioPetiS *. bronze trophy
    Join Date
    Jun 2004
    Location
    "Then I figure the most good good guy will win."
    Posts
    1,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simplified httpd.conf file: Redirect to an "offline" folder?

    Hi,

    Sorry, I am not a server guy, so I apologize in advance if this is a silly question.

    What would the most basic http.conf file that I could use to direct people to an offline folder with a simple index.html page?

    I was told that I need to change the DocumentRoot to this:

    DocumentRoot "/var/apache2/offline"

    In terms of a simplified configuration file, would something like this suffice:

    #
    # Would I have to load any modules???
    #

    DocumentRoot "/var/apache2/offline"

    <Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    </Directory>

    <IfModule dir_module>
    DirectoryIndex index.html
    </IfModule>

    <Files ~ "^<.([Hh][Tt]|[Dd][Ss]_[Ss])">
    Order allow,deny
    Deny from all
    Satisfy All
    </Files>

    <Files "rsrc">
    Order allow,deny
    Deny from all
    Satisfy All
    </Files>

    <Directory ~ ".\.\.namedfork">
    Order allow,deny
    Deny from all
    Satisfy All
    </Directory>

    <IfModule mime_module>

    TypesConfig conf/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    </IfModule>

    DefaultType text/plain
    Any tips ya'll pro Apache guys/gals could send my way would be great.

    Have a nice night,
    Cheers,
    Micky

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    Micky,
    Quote Originally Posted by mhulse View Post
    Sorry, I am not a server guy, so I apologize in advance if this is a silly question.
    The ONLY silly question is the one that goes unasked if you don't know the answer.

    Let me get this straight: You want to redirect someone to an offline folder? That can be done but it will only result in a failed link. Think about it: If the "offline folder" were offline, it could NOT be accessed via an http:// request, could it? In fact, placing information in an OFFLINE folder is a great way to protect it from all but the most serious hack-attack (it can be accessed by PHP and served from a script IN an online folder).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    .* draziW tnioPetiS *. bronze trophy
    Join Date
    Jun 2004
    Location
    "Then I figure the most good good guy will win."
    Posts
    1,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi DK! A billion thanks for the quick reply, I really appreciate your assistance and pro advice.

    Quote Originally Posted by dklynn View Post
    The ONLY silly question is the one that goes unasked if you don't know the answer.
    Hehe, well stated. I totally agree.

    Quote Originally Posted by dklynn View Post
    Let me get this straight: You want to redirect someone to an offline folder? That can be done but it will only result in a failed link. Think about it: If the "offline folder" were offline, it could NOT be accessed via an http:// request, could it? In fact, placing information in an OFFLINE folder is a great way to protect it from all but the most serious hack-attack (it can be accessed by PHP and served from a script IN an online folder).
    Ahhhh, sorry... Maybe I did not explain very well.

    I have a folder located here:

    Code:
    /var/apache2/offline/
    ... and inside is an index.html file that has an "website is offline" message.

    When I take my site down for maintenance, I want to route all incoming traffic to that "offline" folder and have the offline/index.html file load.

    I was told to create a basic/"default settings" httpd.conf file, that could temporarily replace the main/loaded configuration file... After a quick restart of Apache, the "simple" httpd.conf file would show the "offline" message.

    Hopefully that makes more sense. Let me know if I need to explain better.

    I am kinda out of my comfort zone here.

    Thanks so much for your time and help.

    Cheers,
    Micky

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    Micky,

    Oh, a "Website down for maintenance," eh? That's too simple!

    I run (most of) my sites using PHP so index.php in the DirectoryIndex. That leaves index.html unused ... until I need to signify that I've taken a website offline. I leave the index.html there (as well as the index.php) but change the DirectoryIndex from
    Code:
    DirectoryIndex index.php index.html
    to
    Code:
    DirectoryIndex index.html index.php
    Now, that'll work for your DOMAIN but it will leave you to "play" with your website (as well as others that have links into the website).

    The SERIOUS way to keep EVERYONE (yourself included) out of your website is to use mod_rewrite as follows:
    Code:
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^index\.html
    RewriteRule .? index.html [R=302,L]
    # R=302 is a temporary redirect
    Of course, this will also KILL every image, stylesheet, script, etc. If you want to display everything BUT .php scripts, then change the RewriteRule to:
    Code:
    ...
    RewriteRule !\.php$ index.html [R=302,L]
    If you still need access, add another RewriteCond like:
    Code:
    ...
    RewriteCond %{REMOTE_ADDR} !^{your IP address - escape the dot characters}$
    ...
    Clear as mud?

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    .* draziW tnioPetiS *. bronze trophy
    Join Date
    Jun 2004
    Location
    "Then I figure the most good good guy will win."
    Posts
    1,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WOW! Great info! Many many many thanks DK!

    Code:
    RewriteEngine on
    RewriteCond &#37;{REQUEST_URI} !^index\.html
    RewriteRule .? index.html [R=302,L]
    # R=302 is a temporary redirect
    The above should work pretty good I think.

    So, let me see if I understand:

    • If the incoming uri does not end in index.html
    • Rewrite the uri so that it does end index.html and tell google/others that it is a 302 temp. (L means last)


    Quote Originally Posted by dklynn View Post
    Of course, this will also KILL every image, stylesheet, script, etc.
    Sounds like what I need... But does this mean I need to have an alternative index.html page for every folder that does not load index.html by default?

    In fact, the system I am working with uses an obscure language/technology called CSP... Cach&#233; Server Pages.

    In CSP, we had to setup a mod-rewrite to make the index "index.csp" pages load...

    If I wanted to grab all incoming traffic, and re-route them to one specific html file, would this do the trick:

    Code:
    RewriteEngine on
    RewriteCond {REQUEST_URI}
    RewriteRule /from/the/web/root/offline/index.html [R=302,L]
    My main concern is that the httpd.conf file is already pretty complex... Would my only option be to comment out all other mod rewrites?

    Quote Originally Posted by dklynn View Post
    Clear as mud?
    Definitely! Thank you so much for your expert help! Next time you are in Eugene, Oregon, I will you buy you a brew.

    Thanks!
    Micky

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    Micky,

    Code:
    RewriteEngine on
    RewriteCond &#37;{REQUEST_URI} !^index\.html$
    RewriteRule .? index.html [R=302,L]
    # R=302 is a temporary redirect
    • If the incoming uri IS NOT index.html
    • Rewrite the uri so that it IS index.html and tell google/others that it is a 302 temp. (L means last which terminates that block of code)

    Sounds like what I need... But does this mean I need to have an alternative index.html page for every folder that does not load index.html by default?
    No, that means that EVERYTHING is redirected to the index.html in the DocumentRoot - images, js, css, yadda-yadda included! EVERYTHING (to a computer) means EVERYTHING!
    If I wanted to grab all incoming traffic, and re-route them to one specific html file, would this do the trick:
    Code:
    RewriteEngine on
    RewriteCond &{REQUEST_URI} {regex}
    RewriteRule /from/the/web/root/offline/index.html [R=302,L]
    Your code would have NOT worked (500 for the syntax error).
    My main concern is that the httpd.conf file is already pretty complex... Would my only option be to comment out all other mod rewrites?
    Naw, just DELETE them all!

    Use RewriteEngine off before the start of the other nonsense and RewriteEngine on afterward (like PHP's {...}). Gotta save code that has been working for you!

    Thanks! (belch)

    Regards.

    DK
    Last edited by dklynn; Dec 2, 2009 at 19:12. Reason: Closed my [quote]
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  7. #7
    .* draziW tnioPetiS *. bronze trophy
    Join Date
    Jun 2004
    Location
    "Then I figure the most good good guy will win."
    Posts
    1,666
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DK,

    ...

    YOU ROCK!!!

    Thank you!!!!!!!!!!!!

    I will let you know how everything turns out.

    Have a great day/night.

    Cheers,
    Micky

  8. #8
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    Thanks, Micky!

    'Glad to be of service!

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •