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
-
301 Redirects a Year Later
I inherited the digital maintenance of a website that was relaunched a year ago. In looking at Google Analytics, organic search a year later is still down 33%. I fear they did not install 301 Redirects but can't really get a specific answer from them. Is it possible to install them a year later to help with Google indexing and get back some of the organic traffic?
Technical SEO | | stansamples0 -
Pages with 301 redirects showing as 200 when crawled using RogerBot
Hi guys, I recently did an audit for a client and ran a crawl on the site using RogerBot. We quickly noticed that all but one page was showing as status code 200, but we knew that there were a lot of 301 redirects in place. When our developers checked it, they saw the pages as 301s, as did the Moz toolbar. If page A redirected to page B, our developers and the Moz toolbar saw page A as 301 and page B as 200. However the crawl showed both page A and page B as 200. Does anyone have any idea why the crawl may have been showing the status codes as 200? We've checked and the redirect is definitely in place for the user, but our worry is that there could be an issue with duplicate content if a crawler isn't picking up on the 301 redirect. Thanks!
Technical SEO | | Welford-Media0 -
Linking Root Domains after Site-Wide Redirect
(Edited for simplicity) Page #1 on site A has links from 5 different root domains. If I 301 that page to a page on site B that has zero links, will site B gain 5 linking root domains, per the Moz tool? Thanks.
Technical SEO | | ClearPoint0 -
Existing content & 301 redirects
Hi All, I will try to keep this to the point. One of our websites was hit by penguin for unnatural linking. We are building a new site (same business, different domain), but we would like to take some of the pages/content off the old website and use it on our new site. Is it just a case of copying each page onto our new site and 301 redirect the old URL? Or should I just be completely rewording/recreating the old content so it is unique? Any help on this would be great, but I am also open to alternate methods too. Thanks Lewis
Technical SEO | | SO_UK0 -
301 redirect new site design
Hi I'm just setting up some 301 redirects for a new site design about to go live. The old site structure had some 'overview' pages in the urls (without any content) that just 302'd to a sub page. Do i need 301 redirect these overview page urls or since they had no content theres no need and I probably shouldn't or should i ? Also for pages that have no direct equivalent replacement is it still best to 301 to nearest relevant page or just leave it. For example a thank you page that currently shows after user submits email form wont be on new site (since message shows on form page after submission rather than new page). Should i 301 to form page or just leave it ? Cheers Dan
Technical SEO | | Dan-Lawrence0 -
301 Redirect Help
How would you 301 redirect and entire folder to a specific file within the same domain? Scenario www.domain.com/folder to www.domain.com/file.html Thanks for your Input...
Technical SEO | | dhidalgo11 -
301 Redirects on Large Real Estate Website
Hi guys,We are about to move over to a new website and need advice on handling the 301 redirects.We have a large real estate website with around 12,000 pages, a lot of these are properties (about 10,000)On our old website, the url structure for each property is as follows -domainname.com/property/view?property=14863on our new site, the url structure isdomainname.com/properties/view/6137The property ID number is always different from old site to new. The way we see it, we have two options. a.) a manual redirect of each and every property url. A very very long jobb.) a folder level redirect, so redirect the 'property' folder on the old site into the 'properties' folder on new. The con with this one is we are not sure if this is the best route to take, if it is how we would go about it?Some advice would be really appreciated guys. I know there are some hyper intelligent SEO's in here and we need to make sure we handle this right!Many thanks in advance.Mark
Technical SEO | | Nextman0 -
How long should I keep 301 redirects?
I have modified a the URL structure of a whole section of a website and used mod_rewrite 301 redirect to match the new structure. Now that was around 3 months ago and I was wondering how long should I keep this redirect for? As it is a new website I am quite sure that there are no links around with the old URL structure but still I can see the google bot trying from time to time to access the old URL structure. Shouldn't the google bot learn from this 301 redirect and not go anymore for the old URL?
Technical SEO | | socialtowards0