Hello, I built my website again, and because of that I have new URLs for all the texts pages. If I understand right, I need to do "redirect 301" to all the old url. for example: old url: http://www.my-site.com/index.php?page=questions new url: http://www.my-site.com/index.php?page=5 This is example for ionly 1 url. I'm have lots of them. I heard that I have to add code to file ".htaccess" - what is the code to "redirect 301" for the url in my example? BTW - Do I realy need to do "redirect 301"? wouldn't Google will understand that the old URLs are no longer exist and that they moved to new URLs? Thanks
This is the format to use in your .htaccess file. Redirect 301 /index.php?page=questions http://www.my-site.com/index.php?page=5 If .htaccess does not exist in your root directory, just create a new file in a text editor, saving it as .htacess (no extension) Yes, you really need to do a 301 redirect. This tells google that the page has permanently moved to a new location. You don't want to risk google dropping the page from its index if it gets a 404 error response.
I don't think you really need a redirect for that. About Google, its better to don't worry about that, and do some url rewriting. you want to do : I suggest you to do :
DN48 is right. It should be my-site.com/index/questions or my-site.com/index/questions-5/ This is more SEO friendly. You can use .htaccess to redirect, it is better than using php.
Yes I agree with the dihuta. if you choose your new url as below: www.site.com/index/question then here is the rule which redirect 301 for all your pages. RewriteRule ^index/([a-zA-Z0-9-_])$ index.php?page=$1 [NC,L,R=301] This will surely work for you.
Thank you all. What do you mean by" all your pages"? I what to do redricrt only for one url (http://www.my-site.com/index.php?page=questions) to another (http://www.my-site.com/index.php?page=5) can I have the exact code for file ".htaccess" please?
roice, the code you need to use is what fr33lanc3 provided in the first response. What the others are talking about is for implementing search engine friendly URL's.
OK, I did this: Redirect 301 /index.php?page=questions http://www.israeli-guitar.com/index.php?page=5 and its not working for me. what do I do wrong?
Looking at your question again, I see you are not wanting to redirect to a new file, but only changing a value in the query string. A 301 redirect wont work because you are redirecting to the same page. I would suggest writing a function at the top of index.php that would check for the new updates in your page value. You would need to map old values to new values. If you have 10-20, I would just do in code, if you have hundreds, I would probably create a database table to store the new values for easier management. logic would be something like this ==> //array to hold new values to map $mapArr['questions'] = 5; $mapArr['answers'] = 6; ... // value from query string to test $oldPage = $_GET['page']; // test if old page is in array an has new value if (array_key_exists($oldPage, $mapArr)) { $page =$mapArr[$oldPage]; } else { // use value from query string because it has not been remapped $page = _GET['page']; } // continue with logic using page variable ...
Hi fr33lanc3 Thank for your reply All the inbound links on the net, so my site, direct to the main page of the site - index.php the reason I want to do redirct is because I don't want that Google will think I duplicate text...