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. 301: Dynamic URL to Static Page

    301: Dynamic URL to Static Page

    Technical SEO Issues
    7 3 3.9k
    • 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.
    • ohlmanngroup
      ohlmanngroup last edited by

      I've been going around trying to get this dynamic url to redirect in the .htaccess file. I know I'm missing something but can't figure it out.

      Code:

      RewriteEngine on
      RewriteCond %{QUERY_STRING} ^/dynamic-url.php?id=43$
      RewriteRule ^$ http://static/page/url/inserted/here? [R=301,L]

      Suggestions?

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

        No sure exactly what you are trying to do...

        this is something similar does it help? (from Stack Overflow)

        RewriteCond %{QUERY_STRING} ^route=product/category&path=35&page=([0-9]+)$
        RewriteRule ^index.php$ /product/category/35/page_%1? [R=301,L]

        Adam

        ohlmanngroup 1 Reply Last reply Reply Quote 0
        • ohlmanngroup
          ohlmanngroup @NaescentAdam last edited by

          I'm trying to take a dynamic url and redirect (301) it to a static url

          dynamic: /dynamic-url.php?id=43

          static: http://static/page/url/inserted/here

          NaescentAdam 1 Reply Last reply Reply Quote 0
          • NaescentAdam
            NaescentAdam @ohlmanngroup last edited by

            Ahh yes I know what you mean that way. I meant programatically. Are you going to go through all the urls and manually assign them a redirect or are you trying to do one rewrite for multiple urls?

            If the first one you could just use the example I gave you and modify it.

            Also only just noticed I see you haven't escaped your metacharacters. This an example from mine (not using dynamic urls):

            RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
            RewriteCond %{HTTP_HOST} ^www.domain.com$
            RewriteRule ^Old-Page.html$ "http://www.domain.com/New-Page.html" [R=301,L]

            ohlmanngroup 1 Reply Last reply Reply Quote 0
            • ohlmanngroup
              ohlmanngroup @NaescentAdam last edited by

              It is the first one unfortunately it doesn't seem to be working for me.

              NaescentAdam 1 Reply Last reply Reply Quote 0
              • NaescentAdam
                NaescentAdam @ohlmanngroup last edited by

                In that case try my rewrite, like this and escape your metacharacters like . /  - etc..

                RewriteEngine on

                RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
                RewriteCond %{HTTP_HOST} ^www.domain.com$
                RewriteRule ^dynamic-url.php?id=43$ "http://static/page/url/inserted/here" [R=301,L]

                edited that I forgot to escape the - and . in dynamic-url.php

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

                  Hi there,

                  If it's only that URL (not a group of URLs with a pattern to follow) that you need to 301-redirect then you can directly use:

                  RedirectMatch 301 /dynamic-url.php?id=43 http://www.yourdomain.com/static/page/url/inserted/here

                  If this is not the situation please let me know!

                  Thanks,

                  Aleyda

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  • 301 redirect from dynamic url to static page
                    alstam
                    alstam
                    0
                    3
                    297

                  • URL structure change for pages without traffic: 301 redirect or not ?
                    BlueCorona
                    BlueCorona
                    0
                    5
                    96

                  • 301 duplicate content dynamic url
                    dashinfashion
                    dashinfashion
                    0
                    9
                    675

                  • 301 Redirect From Dynamic Page To Static
                    TheDude
                    TheDude
                    1
                    3
                    512

                  • Duplicate pages, overly dynamic URL’s and long URL’s in Magento
                    nageldecoratie
                    nageldecoratie
                    1
                    6
                    4.6k

                  • 301 redirects and Dynamic URLs
                    Barrycliff68
                    Barrycliff68
                    0
                    3
                    1.1k

                  • Google Webmaster Tools reports 404s for plain text. Should I create those URLs and 301 them to actual pages?
                    Martijn_Scheijbeler
                    Martijn_Scheijbeler
                    0
                    2
                    613

                  • Switching ecommerce CMS's - Best Way to write URL 301's and sub pages?
                    tylerfraser
                    tylerfraser
                    0
                    7
                    1.2k

                  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