1 Reply Latest reply on Apr 17, 2013 4:44 PM by Aegis Kleais

    Alias URLS based on directory - Redirect

    weezerboy Level 1

      I have 5 directories in my site that for organizational purposed I copied into one directory named usersites so they all would be in one place.

       

      So I had these 5 directories before the change

       

      website1

      website2

      website3

      website4

      website5

       

      So before the change when my users accessed my site they would access these directories like this

       

      www.mysite.com/website1/mypage.cfm or www.mysite.com/website2/mypage.cfm  etc

       

      So now after the change the directories are in the usersites directory at 

       

      www.mysite.com/usersites/website1/

       

      I dont want to tell all of my users that they need to change their existing urls from

       

      www.mysite.com/website1/pagename.cfm   to  www.mysite.com/usersites/website1/pagename.cfm

       

      Is there a way that when one of my users accessess the  old directory that they will automatically be redirected to the new directory?

       

      Maybe something in the application.cfm?

       

      Just to make sure when a user comes in here www.mysite.com/website1/test.cfm I want them to gets redirected to www.mysite.com/usersites/website1/test.cfm

       

      Thank you!

        • 1. Re: Alias URLS based on directory - Redirect
          Aegis Kleais Level 3

          Depending on the tech you have available, I would use URL Rewriting.  This allows the URL to stay fresh as well.

           

          When a user requests:

           

          http://www.mydomain.com/websiteNumber/page.cfm

           

          Initially it's handed off to the webserver (assuming IIS7)  IIS can then intercept the request and rewrite it before it is passed on for processing.

           

          The above request looks like this to IIS BEFORE URL Rewriting:

           

          /websiteNumber/page.cfm

           

          After the rule is applied, the request will look like:

           

          /usersites/websiteNumber/page.cfm (even though the URL will remain the same)

           

          At that point, once URL rewriting is done, IIS will process the request by looking into the root directory to see if there is a usersites folder, and a websiteNumber folder in that, and then a page.cfm.  And if there is, it sees that the .CFM extension means to hand the request off to ColdFusion, which then process the .cfm page under the belief that the requested URL is '/usersites/websiteNumber/page.cfm'.

           

          The only thing to be mindful of is that if an error occurs, it may expose the path.

          1 person found this helpful