Apache redirects if there are no parameters

I tried looking for this solution and apologized in advance if it was there and I missed it.

I am working on setting up a 301 redirect on apache server to point old pages on CMS to new pages. During the transition, we need to manage the pages on both systems. They have a page that:

  • If there are no GET parameters at the end, you need to redirect to the new CMS
  • if it has GET parameters, it should NOT redirect and should continue to work with the old CMS

I've seen a lot of mod_rewrite rules to do the opposite of what I'm looking for, but not one that only gets activated if there are no GET parameters. I tried the following, but it didn't work:

RewriteCond %{REQUEST_URI} ^/page.php$<br />
RewriteCond %{QUERY_STRING} ^<br />
RewriteRule ^.*$ http://new.domain.com [L,R=301]

      

If someone goes to old.domain.com/page.php they should be redirected to new.domain.com. If someone goes to old.domain.com/page.php?var=1&var=2, they should stay on that domain and not be redirected.

Thanks in advance for any help you could provide,
Dave

+3


source to share





All Articles