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
-
Redirect chain error free htaccess code for website
i want to redirect domain, example.com to https://www.example.com, is anyone can help me to provide redirect chain error free ht-access code. I implemented this htaccess code on the website and mhy site show on the moz redirect chain error RewriteCond %{HTTP_HOST} !=""
Technical SEO | | truehab
RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.)\sHTTP/[0-9.]+$ [OR]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s(./)/+\sHTTP/[0-9.]+$
RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L]0 -
Some SEO 2016 questions
Hello MOZ Community, I have some questions where the following is still working for seo in 2016: Is an exact keyword in the domain still a good start? If a domain contains the most important keyword does one still need subfolders with that keyword in the url? Do you need multiple subpages so the main url becomes stronger? Is linkbuilding still the number one factor? Thank you for your thoughts!
Technical SEO | | mhenze0 -
Mobile website question
Hi Mozzers, A website I manage has a mobile friendly version of their main website and a /m version as well. I was wondering if anyone had any experience in the best way of handling this? Should we just get rid of the /m version and tag the mobile friendly version? Thanks!
Technical SEO | | KarlBantleman0 -
Domains and Hosting Question
I bought hosting for unlimited domains on Godaddy. It's not a dedicated server. It was just $85 a year. I have unlimited latency but a limited amount of "space." I don't know a lot about hosting servers etc... My question is relatively simple. When I go in GoDaddy to my hosting. There is a site that shows up as hosted, and all of the other sites show up under that site in it's directory. If you type the name of the site I bought the hosted package on, then type a forward slash and the name of one of the other sites on the hosting package, you will actually go to the other website. What is this relationship? Is it normal? Does that make all of my websites subdomains of the main site (that I bought the hosting package on)? I don't fully comprehend how this effects everything...
Technical SEO | | JML11790 -
Technical question about site structure using a CMS, redirects, and canonical tag
I have a couple of sites using a particular CMS that creates all of the pages under a content folder, including the home page. So the url is www.example.com/content/default.asp. There is a default.asp in the root directory that redirects to the default page in the content folder using a response.redirect statement and it’s considered a 302 redirect. So all incoming urls, i.e. www.example.com and example.com and www.example.com/ will go to the default.asp which then redirects to www.example.com/ content/default.asp. How does this affect SEO? Should the redirect be a 301? And whether it’s a 301 or a 302, can we have a rel=canonical tag on the page that that is rel=www.example.com? Or does that create some sort of loop? I’ve inherited several sites that use this CMS and need to figure out the best way to handle it.
Technical SEO | | CHutchins1 -
301 redirect or 302
A client of mine has an international company named www.taxglobalizers.com if you come from Holland they 302 redirect you to the www.taxglobalizers.com/en version of the site and if you come from Holland they redirect with a 302 to www.taxglobalizers.com/nl version. I think it is best to change this in a 301 redirect. Am i correct in this? Kind Regards, Ruud
Technical SEO | | RuudHeijnen0 -
Removing 301 Redirects
Is it safe to remove old 301 Redirects from an SEO standpoint and can 301s dramatically affect seo? Prior to switching our old domain over to our new domain, we had (and currently still do) tons of 301 redirects, because of optimizing our file names and structure. Then our old domain was redirected to our new domain in the same redirect file. So that being said, now that our new domain has been up and running for about 3 months, would it be safe for me to get rid of the old 301 redirects and redirect anything that was on our old domain to our new domains home page? This would clean up our redirects tremendously and I hope would help with SEO.
Technical SEO | | hfranz0 -
Question about Hm Pg Redirects
This question is for MichaelC who was helping me with a previous question that is now closed. Please refer to my question with Subject "Double 301 Redirect" It was about redirecting /home.aspx to simply "/" because that was an old URL and we have some backlinks pointing to it. If the best I could do is redirect "/home.aspx" to something like "#hm", would that work, since everything after the hash symbol is ignored? Thanks Clint
Technical SEO | | poolguy0