We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33409
    • 8 Posts
    I have just finished building and launching our new website. I am now faced with the trouble of redirecting all of our .net pages from our old site. For example:

    www.exampe.com/about/why.aspx needs to redirect to www.example.com/about/why or [~56~]

    Does anyone know how to do this in ModX?
      • 16702 ☆ A M B ☆
      • 536 Posts
      one of the options is in .htaccess smiley ...manual

      RewriteEngine on
      RewriteCond %{QUERY_STRING} ^id=13$
      RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]
        palma non sine pulvere
        • 33409
        • 8 Posts
        Hey Kristalin,

        I tried that and wasn’t able to get it going for some reason.. I commented out everything that had re-write on it currently and added that code. I might not have put the old page in there correctly can you show me what the code should look like with the page I referenced above?
          • 8898
          • 181 Posts
          In your .htaccess, try
          RewriteEngine On
          RewriteBase /
          
          RewriteRule ^(/?([^/]+/)*[^/]+)\.aspx$ $1 [L,R=301]

          Now in every URL that ends with ".aspx", this ending should be cut off.

          If this doesn’t work, you can at least see where you’re directed to when you look at the URL field of your browser. Post the result here, and there’ll surely be someone here to help you (I’m going on holiday tomorrow morning cool).

          If you just want to rewrite a few addresses, you could also do this one by one:
          RewriteEngine On
          RewriteBase /
          
          RewriteRule ^(/?about/why)\.aspx$ $1 [L,R=301]
          RewriteRule ^(/?about/why_not)\.aspx$ $1 [L,R=301]
          RewriteRule ^(/?blog/this_is_why)\.aspx$ $1 [L,R=301]


          You could also rewrite all URLs of specific directories:
          RewriteEngine On
          RewriteBase /
          
          RewriteRule ^(/?about/[^/]+)\.aspx$ $1 [L,R=301]
          RewriteRule ^(/?blog/[^/]+)\.aspx$ $1 [L,R=301]


          I hope this helps...

          Cheers,
          Jan
            This message has been ROT-13 encrypted twice for higher security.
            • 8898
            • 181 Posts
            Quote from: zconkle at Jul 22, 2010, 08:06 PM

            I copied the first lines of code in and when I try and go to: www.cytracom.com/about/whycytracom.aspx I am redirected to www.cytracom.com/about/whycytracom

            I need it to go to www.cytracom.com/about/why
            Well, your first example was different... wink

            For this URL use
            RewriteEngine On
            RewriteBase /
            
            RewriteRule ^(/?about/why)cytracom\.aspx$ $1 [L,R=301]

            Everything that is placed inside the brackets will be used as new address, everything outside the brackets will be cut off.

            You could also rewrite to URLs that are totally different. Just an example: If you have an old URL www.example.com/blog/nice-weather-today.aspx that now should be rewritten to www.example.com/new-blog/weather, this should help:
            RewriteEngine On
            RewriteBase /
            
            RewriteRule ^/?blog/nice-weather-today\.aspx$ new-blog/weather [L,R=301]

            Here no brackets are used because no part of the old URL is reused - the new URL is explicitly written down.

            Of course the first two lines are only needed once; you can then add as many RewriteRules as you like.

            Cheers,
            Jan
              This message has been ROT-13 encrypted twice for higher security.