301: Dynamic URL to Static Page
-
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?
-
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
-
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
-
It is the first one unfortunately it doesn't seem to be working for me.
-
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] -
I'm trying to take a dynamic url and redirect (301) it to a static url
dynamic: /dynamic-url.php?id=43
-
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
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
After you remove a 301 redirect that Google has processed, will the new URL retain any of the link equity from the old URL?
Lets say you 301 redirect URL A to URL B, and URL A has some backlinks from other sites. Say you left the 301 redirect in place for a year, and Google had already replaced the old URL with the new URL in the SERPs, would the new URL (B) retain some of the link equity from URL A after the 301 redirect was removed, or does the redirect have to remain in place forever?
Technical SEO | | johnwalkersmith0 -
Trailing slash on the main website - do i need a 301 ? Is my 301 correct?
Hello, Im a bit confused. If i use a tool like majestic to look at my website links, www.example.com and www.example.com**/ have huge difference in their authority.** Do i need to make a 301 redirect to the site with the splash or not? Will google itself understand that they are my main site? Is this the "http://www.website.com.com/"/> correct canonical? Meaning it has trailing splash and also RewriteCond %{HTTP_HOST} ^www.example.com [NC]
Technical SEO | | advertisingcloud
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] - this one has trailing splash, correct?0 -
What are the SEO recommendations for dynamic, personalised page content? (not e-commerce)
Hi, We will have pages on the website that will display different page copy and images for different user personas. The main content (copy, headings, images) will be supplied dynamically and I'm not sure how Google will index the B and C variations of these pages. As far as I know, the page URL won't change and won't have parameters. Google will crawl and index the page content that comes from JavaScript but I don't know which version of the page copy the search robot will index. If we set user agent filters and serve the default page copy to search robots, we might risk having a cloak penalty because users get different content than search robots. Is it better to have URL parameters for version B and C of the content? For example: /page for the default content /page?id=2 for the B version /page?id=3 for the C version The dynamic content comes from the server side, so not all pages copy variations are in the default HTML. I hope my questions make sense. I couldn't find recommendations for this kind of SEO issue.
Technical SEO | | Gyorgy.B1 -
Thousands of 404-pages, duplicate content pages, temporary redirect
Hi, i take over the SEO of a quite large e-commerce-site. After checking crawl issues, there seems to be +3000 4xx client errors, +3000 duplicate content issues and +35000 temporary redirects. I'm quite desperate regarding these results. What would be the most effective way to handle that. It's a magento shop. I'm grateful for any kind of help! Thx,
Technical SEO | | posthumus
boris0 -
Has Google stopped rendering author snippets on SERP pages if the author's G+ page is not actively updated?
Working with a site that has multiple authors and author microformat enabled. The image is rendering for some authors on SERP page and not for others. Difference seems to be having an updated G+ page and not having a constantly updating G+ page. any thoughts?
Technical SEO | | irvingw0 -
Has my 301 home page really worked?
Greetings from 53° 57′ 30″ N, 1° 4′ 49″ W otherwise known as York 🙂 I know a site i'm working on has two versions of the home page e.g.
Technical SEO | | Nightwing
http://www.davidclick.com & http://www.davidclick.com/index.htm This morning I delved into the bowels of the ht access file and this is what happened... Firstly i added redirect 301 /index.htm http://www.davidclick.com nope that broke everything 😞 I then amended to redirect 301 /index http://www.davidclick.com Can anyone re assure me ive done the right thing in terms of resolveing my home page canonical problem? Thanks in advance 🙂0 -
Should I change these "Overly dynamic URLs" ?
Hello, My client have pages that look like this: www.domain.com/blog/index.aspx?blogmonth=1&blogday=10&blogyear=2012&blogid=256 Question 1: SEOMoz say they are overly dynamic. Is it really in this case as the numbers indicate the year, month and day and do not change? Question 2: Should we change the URLs to proper SEO friendly URLs such as www.domain.com/keywords1-keyword2? The pages are already ranking well and we worry that changing the URL may damage the ranking? Do we risk the page to go down in ranking by creating SEO friendly URLs? (and using a 301 to redirect from the old URL)
Technical SEO | | DavidSpivac0 -
When URL rewrite can lead to un pretty URLs
Hi Mozzers. I've a client that has done a little bit of mess rewriting the URLs of its site. In fact, also the data base driven URLs are rewritten, but the dev forgot to change the space with "-", so that now the 95% of the URLs are like this one: http://www.portalesardegna.com/search/Appartamenti e Residence/ Obviously not really a pretty URL. I am not so sure if this issue has an SEO consecuences (in fact, the site ranks pretty well also with those kind of url), but I am thinking more on usability issue. Could you suggest me any easy fix to this rewrite problem?
Technical SEO | | gfiorelli12