The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. Htaccess redirect with question mark

    Htaccess redirect with question mark

    Technical SEO Issues
    3 2 2.2k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • darkanweb
      darkanweb last edited by

      Hi I have a problem setting up my htaccess for a specific page that has a question mark in the link, and one that has a space in the link and also a question mark. So I would like 2 redirects in my htaccess like that:

      www.olddomain.com/page.php?page=pagename1

      to

      www.newdomain.com/newpage1.html

      www.olddomain.com/page.php?page=page name2

      to

      www.newdomain.com/newpage2.html

      I have tried with something like this but doesn't work:

      RewriteEngine on

      RewriteRule ^page.php?page=pagename1 "http://www.newdomain.com/newpage1.html" [R=301,L]

      RewriteRule ^page.php?page=page name2 "http://www.newdomain.com/newpage2.html" [R=301,L]

      Could someone tell me what exactly I have to change?

      Thanks

      1 Reply Last reply Reply Quote 0
      • kchandler
        kchandler last edited by

        Check out this page, about half way down in the article: http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm

        They cover both dynamic query pages and pages with spaces.

        Good luck - kyle

        darkanweb 1 Reply Last reply Reply Quote 0
        • darkanweb
          darkanweb @kchandler last edited by

          Hi kyle thanks for the answer, I have tried with this code:

          RewriteEngine on 
          RewriteCond %{QUERY_STRING} ^id=13$
          RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]

          But it doesn't work. Is it possible that it requires page.php?id=13 to exist? I don't have anymore the file on the server... Trying to reach page.php?id=13 it responds with a 404 error.

          Any solutions?

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          • I have a question about the impact of a root domain redirect on site-wide redirects and slugs.
            Xiano
            Xiano
            0
            2
            72

          • Htaccess redirects
            Tom-Anthony
            Tom-Anthony
            0
            3
            220

          • 301 redirect question
            TheeDigital
            TheeDigital
            0
            5
            128

          • Redirect Question
            Ray-pp
            Ray-pp
            0
            2
            67

          • URL redirect question
            AlanMosley
            AlanMosley
            0
            8
            165

          • Redirect question
            RobertFisher
            RobertFisher
            0
            6
            513

          • Redirect or not to redirect
            AlanMosley
            AlanMosley
            0
            7
            458

          • Question about domain redirects
            TellThemEverything
            TellThemEverything
            0
            8
            1.1k

          Get started with Moz Pro!

          Unlock the power of advanced SEO tools and data-driven insights.

          Start my free trial
          Products
          • Moz Pro
          • Moz Local
          • Moz API
          • Moz Data
          • STAT
          • Product Updates
          Moz Solutions
          • SMB Solutions
          • Agency Solutions
          • Enterprise Solutions
          • Digital Marketers
          Free SEO Tools
          • Domain Authority Checker
          • Link Explorer
          • Keyword Explorer
          • Competitive Research
          • Brand Authority Checker
          • Local Citation Checker
          • MozBar Extension
          • MozCast
          Resources
          • Blog
          • SEO Learning Center
          • Help Hub
          • Beginner's Guide to SEO
          • How-to Guides
          • Moz Academy
          • API Docs
          About Moz
          • About
          • Team
          • Careers
          • Contact
          Why Moz
          • Case Studies
          • Testimonials
          Get Involved
          • Become an Affiliate
          • MozCon
          • Webinars
          • Practical Marketer Series
          • MozPod
          Connect with us

          Contact the Help team

          Join our newsletter
          Moz logo
          © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
          • Accessibility
          • Terms of Use
          • Privacy