.htaccess rewrite domain but keep directory structure and preserve url in address bar - apache

I have copied a Joomla site from one domain to a new domain.
I want to rewrite the domain name only to keep the directory structure.
And I want to keep the original URL in the address bar to preserve SEO ranking.
Joomla is using relative url's, so the real domain name of the new server will not as such be invoked by Joomla.
How to do this in .htaccess on Apache?

And I want to keep the original URL in the address bar to preserve SEO ranking.
That won't help you really, just add proper 301 redirects and make sure you catch as much of the indexed url's with your redirects component within joomla to prevent any dead links (google hates those and will penalize your domain for it). Also add sitemap, upload it to your google webmaster tools and ask google to index it.

Related

Old urls match new urls of site

guys i have one old site which is in joomla (that is not important). The site has unfriendly urls with too munch get parameters. Example of the urls:
http://example.com/index.php?option=com_content&task=view&id=1088&Itemid=245
So we will rebuild this site on custom our platform. The site have too munch urls in forums and so on.
So basicaly we want when you got from the old urls on the site to be redirected to the new post or whatever it is.
Solution what i have think that it will work.
Every article/post have a old url field in the database and you match the new address with the old address.
You have a panel in the admin area Generate htaccess and when you generate htaccess from the admin it get the old htaccess get all matched urls (old/new) and recreate it.
The think is that i have never do this and i don't know what problems could have the system after this.
Anyone who faced this kind of challenge?

guidelines for htaccess code to transition users to new website

Suppose I have an old website with 10 webpages, and I want to deprecate it and move visitors to a new website with 100 webpages.
Two of the webpages of the old website map directly to two corresponding webpages on the new website. All other pages on the old website should go to the new website's home page. How to set that up?
I know I can use .htaccess in the public_html folder of the old website to create some permanent redirect rules for individual pages. So for the two pages that need to map one-to-one, I can do:
Redirect 301 /oldfile1.htm http://www.example.net/newfile1.htm
Redirect 301 /def/oldfile2.htm http://www.example.net/123/456/newfile2.htm
But what about all the other webpages on the old website? This is where my knowledge of .htaccess lacks. Does the .htaccess stop executing when it reaches one of the redirects above? If so, then perhaps I simply place the following AFTER the above code to catch the remaining pages?
Redirect 301 / http://www.example.net/
Or, something else? Also, will the redirect directly above map all webpages it sees to the home page of the new website (I assume so), or a matching directory/webpage page on the new website? -- That is, I don't want the situation where http://www.olddomain.com/abc/Oldfile1234.html takes users to http://www.example.net/abc/Oldfile1234.html on the new website (rather, it should take users to http://www.example.net) since most webpages do not map one-to-one.
Lastly, in the .htaccess file on the old website public_html directory, how to account for users coming from https versus http, and www versus non-www URLs?
I'm hoping there's common strategy people use for this sort of thing, since it should be fairly common, so I don't have to re-invent one.
You should be using RedirectMatch for precise matching using regular expressions. You can place these rules in root .htaccess:
RedirectMatch 301 ^/oldfile1\.htm$ http://www.example.net/newfile1.htm
RedirectMatch 301 ^/def/oldfile2\.htm$ http://www.example.net/123/456/newfile2.htm
RedirectMatch 301 ^ http://www.example.net/

Is Addon domain affecting SEO

I am just a learn in the field of SEO and i have a main domain and an addon domains. Both have separate websites. Consider main.com is my main domain and addon.com is my addon domain name which is pointed to a sub directory called "addon".
I can access addon.com by using the following 3 ways.
addon.com
main.com/addon
addon.main.com
Are these urls are indexed separately by search engines? If so how can i prevent this?
Does Search engine think main.com/addon as a page in the main.com?
I am not sure i need to worry about all these things or just leave it as it is. I searched to google but couldn't find a right answer.
It may be too late to answer. However, it may benefit others.
Primarydomain and subdomain or addon-domain will not be linked by the search engines automatically, unless you link them purposefully or inadvertently. Except all conditions are true:
Your web root normally public_html has no index page
Directory indexing of your web root is opened, eventually
exposing/linking your sub-folder -which is attached to your
addon-domain- to google and entire world.
In that scenario robots.txt solution is not recommended, because search engines may ignore robot.txt rules.
Reference
Google will only index pages if they are linked to or listed in the sitemap. You can stop the addon.main.com or main.com/addon being indexed by using noindex tags:
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
or disallowing it in the robots.txt
The search engine will consider main.com/addon as a page of main.com - if sites are completely separate i'd recommend using a separate domain (preferably a keyword rich domain) but it's up to you really
We have three domain names with the same content. For the three domains, it will return a 200 OK HTTP code. It will look like duplicates of the same content. If there is a canonical tag on every page it will be better.
The best would be to create a redirection on the subdomain panel in cpanel so that at least addon.main.com would redirect to addon.com
Then, you can add a robots.txt to the root path of the primary domain and add
user-agent:*
disallow:/
so that no robot will visit main.com/addon
Google gives less weight to subdomain hosted site of another domain.
Superbad for SEO
If you are hosting for SEO and love the convenience of cPanel, then forget hosting domains as addon domains.
#Vasanthan R.P.
Its an excellent question, often overlooked by SEO professionals. +1 for you

How to tell Google a page has moved?

We have #1 and #2 spots we would like to keep, but because of the way things were jumbled we have to migrate to a new domain.
We do not want the new domain to be penalized for duplicate content, we want it to naturally take the spot on Google.
How do we tell Google our page has moved?
301 redirects are the recommended way to do this according to Google themselves. I tend to perform 301's using a .htaccess file (a few different methods here) but it can also be done using PHP like this:
header('Location: '.$newlocation, true, 301)
What seengee user has answered is perfect.
Have a look to Google Webmaster Tools too; there's a specific option for Address change.
Change of address
If you're planning to move your site to a new domain, use the Change of Address tool to tell Google about your new URL. This will help us update our index faster and smooth the transition for your users.
For best results, follow these steps:
Set up the new site
Review our guidelines for moving your site to a new domain. Set up your content on your new domain, then make sure all internal links point to the new domain.
Redirect all traffic from the old site
Use a 301 redirect to permanently redirect the pages on your old site to your new site. This tells users and search engines that your site has permanently moved. Ask webmasters to update their links to point to your new domain and make sure incoming links to your old site are redirected correctly using the 301 redirects.
Add your new site to Webmaster Tools
Make sure you have added and verified your new domain.
Tell us the URL of your new domain
Try this: https://www.google.com/webmasters/tools add both domains there and then, go Change of address.
Http 301 Request is used for Permanent Redirect the old website's content,URL and Links to New Website URL. Google Never Penalize the New Website for Duplicate content.
what about "Keyword" you use in meta for performing in SERP result. After redirection how you manage them.
position before Redirection , after redirection have same OR not.
AS SEO purpose don't make Redirection withour proper plan. First make proper optimization of "B" page before "A" redirect ( 301, 302 ) "B" page.
Dont make 302 Redirect , its spammy after 3 months, why within 20 Days SERP catche show "B" page instead of "A" page.
in the end : Before Redirection - Optimize the Destination URl - for Benefit SEOand business
Have a Nice Day ... Thanks
Google itself detect your web page if you implemented the 301, 302 or 404 redirection. But if you want to tell google that you have moved your page then:
Go to google webmaster tool
In Crawl section there is an option of Fetch as Google.
Just enter your url and check the fetch status, you will find that google will index your new url.
in google webmaster tools click on change of site address.
firstly you need to put content on new website where you want to redirect the website.
redirect usingold website by using HTTP 301 code and after verify in google webmaster tools.
Do 301 redirects. This will tell the search engines that the pages have moved and where they are now. This also associates the old URL with the new URL for Google which means all of your old incoming links will now be redirects to your new pages. Also use Google Webmaster Tools to submit XML sitemap.
In both Google and Bing Webmaster tools, you can notify a change of address. I will warn you, however, that when changing domains, you're not going to keep your current rankings.
Submit a change of address notice in Webmaster tools
Do 1:1 page redirecting (redirect all other pages that can't be mapped to a similar page to your homepage)
Submit an up-to-date sitemap
This should help:
https://support.google.com/webmasters/answer/83106?hl=en
http://moz.com/blog/achieving-an-seo-friendly-domain-migration-the-infographic

Multiple Domain name

I have a customer that been on the web for some time. They have bought a domain name that describe it product, and a second one more up to date. Now that company has evolved to something more general and has bought a 3rd domain - something like:
vegetables.com (2005)
ecolo-vegetables.com (2006)
good-health-eating.com (2009)
Here are my questions:
What is the bet way to get all those domains under the new name?
The new name is unknown to search engine and other linker, I don't want to lose the ranking, so what is the best way to keep that ranking?
Can I point URLs to the "best" ranked domain?
What append to the backlinker? they link to which domain?
The new domain has a "-" in the name... which is really good to SEO but a little unnatural to type, should I get the no dash version too?
n.b. It make sense to redirect all the domain under the same, but will you choose the oldest (with modrewrite) or the newest but with no life under it's belt (so it doesn't exist anywhere in search engine)
another p.s. Some will tell me to redirect with .htaccess, but should I change the dns to point to the last .com. which solution is better
Are all three sites "Different" or do they point to the same website/content?
Use 301 Redirects to redirect your old domain names to the new domain names. If all domains are pointing to the same website, make sure you also use the Canonical Tag on all your pages.
If you 301 Redirect from the old domain names / urls, your rankings will be transfered to your new domain/pages. (the only exception to this may be any extra points you get from embedded keywords in your old domain names).
You should point old urls to your "new" urls/domain. Rankings and link juice should/will be transfered to the new urls/domain.
Ideally all your backlinks should update their links to the new domain, but it doesn't really matter. If the old domains are 301 redirecting to the new domain anyway, point to the old domain is just like pointing to the new domain.
Definitely get the no-dash version of the domain as well and just have it 301 redirect to the actual domain you want to target.
I'll give this a go.
1. You could possibly have redirects or just allow the DNS of the domain to point to the new (desired) website.
2. It's not hard to understand SEO (Search Engine Optimization) nowadays - ensuring you have the correct meta tags and other SE info will give you a big helping hand. There isn't any way of transferring SE ranks.
3. That's possible. You could have ABCDEF.COM at number 3 on google, but then set ABCDEF.COM to redirect to GHIJKL.COM.
4. If you set up redirects, and the new site has the same content as the old one, there is the possiblity of setting up your DNS and your redirect to redirect to the new version of the previous page on the new website.
( I don't think I worded that very well, hope you catch my drift )
5. Out of pure experience I'd say yes, get both. That way you can market to your customer audience as ABCDEF.com, but show to SEs as AB-CD-EF.COM.
Here is the best answer i got from this link
302 and 301 Redirects
When a request for a page or URL is
made by a browser, agent or spider,
the web server where the page is
hosted checks a file called
'.htaccess'. This file contains
instructions on how to handle specific
requests and also plays a key role in
security. The '.htaccess' file can be
modified so that it instructs
browsers, agents or spiders that the
page has either temporarily moved (302
redirect) or permanently moved (301
redirect). It is usually possible to
implement this redirect without
messing with the '.htaccess' file
directly, using your web host's
control panel instead.
From a search engine perspective, 301
redirects are the only acceptable way
to redirect URLs. In the case of
moved pages, search engines will index
only the new URL, but will transfer
link popularity from the old URL to
the new one so that search engine
rankings are not affected. The same
behavior occurs when additional
domains are set to point to the main
domain through a 301 redirect.
And the last word : from this link that just confirm what i know know !
First off, ensure you're using "301 redirects" rather than "302 redirects" or the link juice (PageRank) won't transfer to the destination URL. You can verify that 301s (not 302s) are in place by using a "server header checker" like this one. Only a 301 tells engines the previous URL has moved permanently and thus forwards the page's link equity to the new location.