Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to redirect an entire directory of pages?

    Hey Guys

    I desperately need some help. We run an asp forum script, called "Web Wiz" and we want to rename the directory it is in
    So now, we urgently need a way to redirect all requests going to the old forum, to the new one.

    We are on a windows server 2005. I've been googeling like crazy, but doesn't seem like there's an easy way to do it like
    php's mod_rewrite. Can anyone please tell me if there is ANY way at all that this can be done without having to ask my host
    to install any scripts, or set anything through IIS?

    Is it possible at all?
    I don't know anything about asp. I'm actually more into php.

    A site mentioned something about it being possible when making use of your 404 error file. But it didn't have a lot of information on it...

    Thanx
    Cloe

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,536
    Thanks
    80
    Thanked 4,490 Times in 4,454 Posts
    I'm not sure Windows Server 2005 can use IIS 7. If it can, IIS 7 has a way to do this that's almost as usable as Apache's system.

    But in any case, you could do it with a custom 404 error page handler. Does your ISP allow you to set a custom error handler? In particular for 404 errors?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,536
    Thanks
    80
    Thanked 4,490 Times in 4,454 Posts
    FWIW, if you can install a custom 404 error handler, and if you make it an ASP page, then the page that is not found is passed to the ASP error handling page as part of the query string. In particular, if you do
    Code:
    qs = Request.QueryString
    then your qs variable will have a string that looks like this:
    Code:
    404;http://www.yoursitename.com:80/subdir/missingpage.ext
    so you can then parse that string and figure out what page was requested and write some simple code to redirect the user to the new page.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey Old_Pedant

    Thank you so much for the reply. And, yes, my host do allow me to use custom 404 handling.

    But, I have no idea how to create a 404 page than can do that. Any chance that you can give me the full code?

    Also, I read this article:
    http://www.stokia.com/support/misc/w...-redirect.aspx

    and it said to create a web.config with this code:

    <?xml version="1.0"?>
    <configuration>
    <system.webServer>
    <httpRedirect enabled="true" destination="http://foo.com/newdir" httpResponseStatus="Permanent" />
    </system.webServer>
    </configuration>

    And then place it inside the old directory.
    which I did, but then I get a 404 error.....

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,536
    Thanks
    80
    Thanked 4,490 Times in 4,454 Posts
    Did you not read the TITLE of that article on stokia.com?
    Using web.config - Redirecting browsers with 301, 302, and 307 status codes on IIS 7 and IIS 7.5
    Again, I say, I'm not sure you can use IIS 7 on Windows Server 2005. The stuff he shows there DOES NOT WORK on IIS 6 and below.

    ********

    I can't give you full code for a 404 handler without knowing the structure of the directories, both old and new. (Not what files are in the directories, just what the hierarchy of the directories was/is.)
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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