Htaccess redirect with question mark
-
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
-
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?
-
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
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
-
Redirects Advice
We have many redirects in place - and sometimes 2 in a chain. Is there a recommended time you should have a redirect in place?
Technical SEO | | Caroline_Ardmoor0 -
Recently migrated to https version of volusion site. 301 redirect link chain question
I recently migrated to a https version of a volusion site. They have some type of internal 301 redirect method to accommodate for the entire site. I have also used the 301 redirect manager to redirect categories and pages which I have changed. The question is if I have changed a page internally in the redirect manager from say source. /bluewidget to say. target. /superbluewidget is it wiser or even possible to do it this way to reduce the redirect chain from 3 to 2 steps source. /bluewidget to. target https://www.example/superbluewidget can a relative link be targeted to a full url to reduce steps in a 301 redirect link chain. Thanks
Technical SEO | | mrkingsley0 -
URL structuring / redirect question
Hi there, I have a URL structuring / redirect question. I have many pages on my site but I set each page up to fall under one of two folders as I serve two unique markets and want each side to be indexed properly. I have SIDE A: www.domain/FOLDER-A.com and SIDE B: www.domain/FOLDER-B. The problem is that I have a page for www.domain.com and www.domain/FOLDER-A/page1.com but I do NOT have a page for www.domain/FOLDER-A. The reason for this is that I've opted to make what would be www.domain/FOLDER-A be www.domain.com and act the primary landing page the site. As a result, there is no page located at www.domain/FOLDER-A. My WordPress template (Divi by Elegant Themes) forced me to create a blank page to be able to build off the FOLDER-A framework. My question is that given I am forced to have this blank page, do I leave it be or create a 302 or 307 redirect to www.domain.com? I fear using a 301 redirect given I may want to utilize this page for content at some point in the future. This isn't the easiest post to follow so please let me know if I need to restate the question. Many thanks in advance!
Technical SEO | | KurtWSEO0 -
One more redirect question
If there are two URLs like below: example.com/toys/batman-toys
Technical SEO | | IceIcebaby
example.com/birthday/batman-toys Both have the exact same everything, except URL key. The first example ranks for all KWs and search terms in the SEs. Does having the second page hurt my ranking potential for the first page? Should I redirect the 2nd page to the first or just leave it? As always, thanks for your help.0 -
.htaccess redirects
I've done some research but can't find a good answer to this question. Here's my situation: Site redirects from example.com to www.example.com just fine. However, it doesn't work so well for internal pages. My site incorrectly redirects (non-www) example.com/page2 to www.example.com when it should instead go to www.example.com/page2 So I need a method to redirect non-www internal pages to www versions. Currently I have this in my .htaccess - do I need to modify the rules? RewriteEngine on
Technical SEO | | 3plains
RewriteCond %{HTTP_HOST} !^www.example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L] Thanks0 -
301 redirect chains
Hi everyone, I've had my site for a while now and have changed the structure a number of times. I'm confident my 301's work well and am not concerned about dead ends on my site. My question is, is there a way to find 301 redirect chains? i.e. can I export my link data from webmaster tools and run it through some software that tells me how many steps my 301's are taking to get to the final page? I don't know for sure that there are long 301 chains in my link structure, but I have a suspicion and it's very hard to check by going through them manually. Thanks in advance Will
Technical SEO | | madegood0 -
Redirecting Domains
Hi Everybody, My clients owns a lot of domains related to his website. I redirected them to the website. So his website is: www.vallnord.com but if you type Vallnordski, vallnordsnow, etc etc they will go to the website, but they will not change the url and will keep vallnordski, vallnordsnow instead of going to vallnord.com Not very clear actually, so if you have 20 seconds to type them you will see it very clear. I was wondering if this was a good practice or it is better to actually redirect someone completely (If they type vallnordski.com take them to vallnord.com)? Is redirecting a good SEO practice? Regards, Guido.
Technical SEO | | SilbertAd0 -
Redirecting According to the occasion
We have loads of different departments that relate to specific occasions (e.g. Christmas, mothers day, father day etc), they all have good PR and inbound links etc and most of them rank well for the specific occasion. What I was thinking is that I could redirect all of the occasions that aren’t in use and send the traffic to the valid occasion live at the moment. So I would 301 all the Christmas pages to our valentine’s day main page. Then once valentines is gone I will redirect Christmas and valentines to the mothers day main page and so on. So this would be constantly switching as different occasions come along. Can you see any possible negative problems? Is there any chance that if I redirect Christmas for example, and then when Christmas comes we remove the redirect, could it harm the Christmas page?
Technical SEO | | steliosp210