301 redirect problems on site not yet moved
-
I have re-designed one of my sites, the old site is all static pages on a Windows server, I have made the new sites and it is on a new server and is running on Wordpress.
I have just finished testing it and so am nearly ready to switch over the nameservers to the new server, however I'm having some problems with 301 redirects.
I have tried to set up a few 301 redirects on the new server to test before I change nameservers but they don't appear to be working. I would have imagined that they should (even though the actual page isn't hosted on the new server) or am I being very stupid here and I can't test a 301 redirect until the nameservers have been changed.
Redirect 301 /magazines.htm http://.../~account/magazine-freebies
Obviously the above with the stars (*) is the server address and route to my account.
-
Ah...Great news!
Glad to help and I hope the new site will do well for you
Sha
-
Hi Sha,
yes it all works, I think my problem was because of trying it on a test server etc.
You have abeen a great help!
-
Hi Wardy,
Check your Private Messages please.
Also, a couple of questions.
- Is the file called .htaccess?
- I the page magazine-freebies a static URL or a Wordpress Blog Category Page?
Please make your .htaccess file look like this
RewriteEngine On
RewriteRule ^/magazines.htm$ /magazine-freebies
Just these two lines, and test to see if it works.
Sha
-
Thanks again for the reply and being patient!
It still isn't working for me.
Obviosuly magazines.htm hasn't been uploaded at any point on the new server but that won't make any difference would it?
-
Hi Wardy,
I think we are nearly there
This is what the first block of your .htaccess should look like:
Options +FollowSymLinks
RewriteEngine On**RewriteRule ^/magazines.htm$ /magazine-freebies [R=301,L]**RewriteCond %{QUERY_STRING} (<|%3C).script.(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]The rest remains the same, but you will need to remove the old rule from the end of the file.
Hope that helps,
Sha
-
Thanks for the reply again Sha!
So I have put
Redirect 301 /magazines.htm http://edit/~mysite/magazine-freebies
at the very top of the .htaccess but the redirect still does not take place.
This is how it now looks. I'm sorry if I'm being daft here by the way!
Redirect 301 /magazines.htm http://edit/~mysite/magazine-freebiesagazine-freebies
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} (<|%3C).script.(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]BEGIN WordPress
<ifmodule mod_rewrite.c="">RewriteEngine On
RewriteBase /~freefsuk/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~freefsuk/index.php [L]</ifmodule>END WordPress
Options -Indexes
protect the htaccess file
<files .htaccess="">order allow,deny
deny from all</files>protect wpconfig.php
<files wp-config.php="">order allow,deny
deny from all</files><files wp-login.php="">Order Deny,Allow
Deny from All
Allow from ...**</files> -
Hi Wardy,
The .htaccess file is read from top to bottom and the first Rule which matches is the Rule that will be used. This means that currently, your Wordpress Rule is a "catch-all" and the 301 will never be executed.
So, the 301 needs to be placed above the Wordpress Rule in the .htaccess
Hope this helps,
Sha
-
Yes this is correct. Although I've tried it with the old page on the new server and with the old page not there on the new server but I can't get the re-direct to work.
Below is the contents of my .htaccess file.
Thankyou for your help!
BEGIN WordPress
<ifmodule mod_rewrite.c="">RewriteEngine On
RewriteBase /~freefsuk/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~freefsuk/index.php [L]</ifmodule>END WordPress
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} (<|%3C).script.(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]Options -Indexes
protect the htaccess file
<files .htaccess="">order allow,deny
deny from all</files>protect wpconfig.php
<files wp-config.php="">order allow,deny
deny from all</files><files wp-login.php="">Order Deny,Allow
Deny from All
Allow from ...*</files>Redirect 301 /magazines.htm http://edit/~mysite/magazine-freebies
-
If you post the content of your .htaccess file we can see if there is a problem with your syntax.
Other things to remember:
-
Don't qualify your FROM or TO (when you fail over your domain the .htaccess will break the site
-
Remember that your WordPress installation will break when you fail over your domain as it has been installed to your test domain.
Hope that helps,
Sha
-
-
OK, so what you are actually trying to do is redirect from one page on the new server to another page on the new server, regardless of anything that is happening on the old server?
Sha
-
Sorry, I thought as I was typing it that it might come across slightly confusing!
www.mysite.co.uk (old versions) is still live on current hosting.
The re-design of www.mysite.co.uk is ready and has been uploaded to a new server.
I have not changed the nameservers of www.mysite.co.uk to point to the new server yet and so the new re-designed site can only be viewed by visiting the physical address of where it is located on the new server: http://123.12.123.12/~mysite
However, I tried to just set up a test 301 redirect on the new server to test my 301 redirects would be working when I do change the nameservers from old to new server but they don't appear to work.
e.g. I tried to test the 301 by
http://123.12.123.12/~mysite/magazines.htm (no actual page there but represents www.mysites.co.uk/magzines.htm when I do change nameservers)
Set up 301 redirect to try and take this to http://123.12.123.12/~mysite/magazine-freebies
So really the existing old site doesn't play any part in this as I am testing it all on the new server first?
Does this make any more sence or made it even more confusing?
-
Hi Wardy,
Are you saying that the domain you wish to redirect to is not yet hosted on that server or did I lose you along the way?
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
-
Unsolved URL dynamic structure issue for new global site where I will redirect multiple well-working sites.
Dear all, We are working on a new platform called [https://www.piktalent.com](link url), were basically we aim to redirect many smaller sites we have with quite a lot of SEO traffic related to internships. Our previous sites are some like www.spain-internship.com, www.europe-internship.com and other similars we have (around 9). Our idea is to smoothly redirect a bit by a bit many of the sites to this new platform which is a custom made site in python and node, much more scalable and willing to develop app, etc etc etc...to become a bigger platform. For the new site, we decided to create 3 areas for the main content: piktalent.com/opportunities (all the vacancies) , piktalent.com/internships and piktalent.com/jobs so we can categorize the different types of pages and things we have and under opportunities we have all the vacancies. The problem comes with the site when we generate the diferent static landings and dynamic searches. We have static landing pages generated like www.piktalent.com/internships/madrid but dynamically it also generates www.piktalent.com/opportunities?search=madrid. Also, most of the searches will generate that type of urls, not following the structure of Domain name / type of vacancy/ city / name of the vacancy following the dynamic search structure. I have been thinking 2 potential solutions for this, either applying canonicals, or adding the suffix in webmasters as non index.... but... What do you think is the right approach for this? I am worried about potential duplicate content and conflicts between static content dynamic one. My CTO insists that the dynamic has to be like that but.... I am not 100% sure. Someone can provide input on this? Is there a way to block the dynamic urls generated? Someone with a similar experience? Regards,
Technical SEO | | Jose_jimenez0 -
Is 301 redirect the only way when using Vanity URLs?
We have been using vanity urls for some of our pages. Mostly the pages that have a vanity URL have a long URL length. But now the problem is, the vanity URL is getting displayed on the search engine when the particular keyword related to the page is entered. I checked the google search console, the vanity URL is indexed and the original URL remains unindexed. What should I do? Is adding 301 redirect to the vanity URLs are solution? Since some of vanity URLs are not redirecting to the original. Some of the original pages are not getting traffic. Also, can using canonical tag help?
Technical SEO | | tejasbansode0 -
Redirecting 301 or 302?
Hi, I think the part of this question has been already discussed, but not exactly the same, I think. My site requires authentication for member page. When a user try to go to member area, we redirect to 3rd party to do the authentication. 1. user clicks a link to www.mysite.com/member/contents.html
Technical SEO | | HypermediaSystems
2. www.myauthenticate.com/login?h=somehashuniquehash454859428778545 (enters id/pass)
3. login success => redirect back to www.mysite.com/member/contents.html We are doing it 302, temporary redirect. But moz crawler error seems to suggest we should do it 301.
So my question is:
A. Should we do it 301???
B. If we do 301, what happens to myauthenticate.com? since it has hashtag, I am afraid it could create a lot of duplicate contents on myauthenticate.com side... Thank you so much for your help in advance...0 -
Increase 404 errors or 301 redirects?
Hi all, I'm working on an e-commerce site that sells products that may only be available for a certain period of time. Eg. A product may only be selling for 1 year and then be permanently out of stock. When a product goes out of stock, the page is removed from the site regardless of any links it may have gotten over time. I am trying to figure out the best way to handle these permanently out of stock pages. At the moment, the site is set up to return a 404 page for each of these products. There are currently 600 (and increasing) instances of this appearing on Google Webmasters. I have read that too many 404 errors may have a negative impact on your site, and so thought I might 301 redirect these URLs to a more appropriate page. However I've also read that too many 301 redirects may have a negative impact on your site. I foresee this to be an issue several years down the road when the site has thousands of expired products which will result in thousands of 404 errors or 301 redirects depending on which route I take. Which would be the better route? Is there a better solution?
Technical SEO | | Oxfordcomma0 -
Can you do a 301 redirect without a hosting account?
Trying to retire domain1 and 301 it to domain2 - just don't want to get stuck having to pay the old hosting provider simply to serve a .htaccess file with the redirect rule.
Technical SEO | | TitanDigital0 -
To 301 redirect or not to 301 redirect? duplicate content problem www.domain.com and www.domain.com/en/
Hello, If your website is getting flagged for duplicate content from your main domain www.domain.com and your multilingual english domain www.domain.com/en/ is it wise to 301 redirect the english multilingual website to the main site? Please advise. We've recently installed the joomish component to one of our joomla websites in an effort to streamline a spanish translation of the website. The translation was a success and the new spanish webpages were indexed but unfortunately one of the web developers enabled the english part of the component and some english webpages were also indexed under the multilingual english domain www.domain.com/en/ and that flagged us for duplicate content. I added a 301 redirect to redirect all visitors from the www.domain/en/ webpages to the main www.domain.com/ webpages. But is that the proper way of handling this problem? Please advise.
Technical SEO | | Chris-CA0 -
Quick Seo question regarding 301 redirect
Hi everyone and thank you for showing interested in my problem and for helping me out with this easy thing i have going on Here is how it puts out : I have 2 websites, same niche, mostly same keywords. Site #1 holding strong on google #2 ranking for months now. Site #2 was holding strong in google top 10 rankings until 2 weeks ago when it got sandboxed for some reason I want to use a 301 permanent redirect from Site #2 to Site #1 to pass all the link juice onto Site #1 and hopefully beat the #1 spot The question: Will this affect Site #1 is anyway, considering Site #2 is in somehow sandbox ( i assume that, since he dropped more then 70 positions over night ) Is thins a good think to do or i risk damaging Site #1 by doing this ? Thanks allot in advance. Best regards,
Technical SEO | | caw_ro
Trinca Alexandru0 -
Any issues with lots of pages issuing 301 redirects?
Hi all, I'm working on a site redesign and it is possible the new site could issue a lot of 301 redirects as we may migrate from one forum solution to another. Is there any issue with crawlers getting a lot of 301 redirects from a site? Thanks Nick
Technical SEO | | nickswan0