We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30912
    • 463 Posts
    Hi,

    Im trying to figure out the corect rewrite rules for moving a site from asp.net to a new modx controlled site

    The old site goes currently to something like

    http://www.url.co.uk/prod1.asp?ID=217 


    I then want this prod1.asp?ID=217 to go to example-page.html

    Below i have added what i think is right but this is new to me so i would appreciate any help.

    RewriteRule ^prod1.asp?ID=217$ http://www.url.co.uk/example-page.html [R=301,L]


    If anyone kows the correct syntax and can point me in the right diraction i would appreciate it.

    Thanks

    Tyr
      • 4310
      • 2,310 Posts
      Have you tried :
      RewriteRule ^prod1.asp\?ID\=217$ example-page.html [R=301,L]
        • 30912
        • 463 Posts
        Would that work if im coming from domain to a different one,

        i.e old domain > new domain/example-page.html

        Cheers

        Tyr
          • 4310
          • 2,310 Posts
          Should do :
          RewriteRule ^prod1.asp\?ID\=217$ http://www.new-domain.co.uk/example-page.html [R=301,L]

          Mind you if it’s an ASP site won’t it be on a Windows server?
          If it is, this would only work if you have something like ISAPI Rewrite installed to interpret the .htaccess file.
            • 30912
            • 463 Posts
            Hi,

            It was on an IIS server its not on our PHP server, i’ll try them and see what happens

            Edit:

            i tried the new rewritess and its displaying an Internal error, ive pm’d you my redirects thanks for your help
              • 4310
              • 2,310 Posts
              In case anyone else has similar redirect needs, here’s the code from the .htaccess file that solved the problem :
              Based on an example by netprophet.
              # For full documentation and other suggested options, please see
              # http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions
              # including for unexpected logouts in multi-server/cloud environments
              # and especially for the first three commented out rules
              
              #php_flag register_globals Off
              #AddDefaultCharset utf-8
              #php_value date.timezone Europe/Moscow
              
              Options +FollowSymlinks
              RewriteEngine On
              RewriteBase /
              
              # Fix Apache internal dummy connections from breaking [(site_url)] cache
              RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
              RewriteRule .* - [F,L]
              
              # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
              RewriteCond %{HTTP_HOST} .
              RewriteCond %{HTTP_HOST} !^www\.your-domain\.co\.uk [NC]
              RewriteRule ^(.*) http://www.your-domain.co.uk/$1 [R=301,L]
              
              # Exclude /assets and /manager directories from rewrite rules
              RewriteRule ^(manager|assets) - [L]
              
              # For Friendly URLs
              RewriteCond %{REQUEST_URI} !^/(prod1|company|prod_detail|enquire|print_product_page).asp
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
              
              RewriteCond %{QUERY_STRING}  ^ID=217$
              RewriteRule ^prod1.asp$ /a-confident-plumber-in-weeks.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=201$
              RewriteRule ^prod1.asp$ /? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=81$
              RewriteRule ^prod1.asp$ /about-us.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=214$
              RewriteRule ^prod1.asp$ /your-plumbing-questions-answered.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=226$
              RewriteRule ^prod1.asp$ /part-p-defined-course.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=224$
              RewriteRule ^prod1.asp$ /unvented-hot-water.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=234$
              RewriteRule ^prod1.asp$ /city-and-guilds-6129-level-2-technical-certificate-in-plumbing.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=225$
              RewriteRule ^prod1.asp$ /water-regulations.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=235$
              RewriteRule ^prod1.asp$ /funding.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=223$
              RewriteRule ^prod1.asp$ /our-plumbing-courses.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=220$
              RewriteRule ^prod1.asp$ /our-plumbing-courses.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=218$
              RewriteRule ^prod1.asp$ /our-plumbing-courses.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=221$
              RewriteRule ^prod1.asp$ /our-plumbing-courses.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=215$
              RewriteRule ^prod1.asp$ /? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=210$
              RewriteRule ^prod1.asp$ /our-plumbing-courses.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^ID=222$
              RewriteRule ^prod1.asp$ /part-p-defined-course.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^prod_id=51$
              RewriteRule ^company.asp$ /privacy-policy.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^prod_id=8161$
              RewriteRule ^prod_detail.asp$ /our-plumbing-courses.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^id=8161$
              RewriteRule ^enquire.asp$ /contact-us.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^id=8165$
              RewriteRule ^enquire.asp$ /contact-us.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^id=8162$
              RewriteRule ^enquire.asp$ /contact-us.html? [R=301,L]
              RewriteCond %{QUERY_STRING}  ^id=8166$
              RewriteRule ^print_product_page.asp$ /part-p-defined-course.html? [R=301,L]