Currently I have my companies blog on the same server as our main web app - as in example.com/blog
What would be the easiest way to move the blog to a different server yet still let users either access the blog at example.com/blog or blog.example.com?
Issue 301 HTTP redirects from website.com/blog to blog.website.com
The specifics depend on the server.
The answer that I provide is assuming that you are using Apache as the webserver as this is what I am familiar with. If you are using IIS then you may be able to find a similar solution but I cannot guarantee this.
In the past I have come across similar issues, whereby a client is hosting their main website at www.mydomain.com but their blog is hosted by their marketing guys at blog.mydomain.com. For SEO purposes it ca be beneficial to have the blog appear at www.mydomain.com/blog although this is not physically possible due to the nature of DNS protocols.
The answer is to use an Apache module called mod_proxy which allows you to map the url /blog to a subdomain and this is invisible to the end-user and, more importantly, search engines. CodeHaus have published a good article on Configuring mod_proxy (update 2016: link leading nowhere) and you may like to have a read.
mod_proxy is quite complex and it can take a while to get the settings correct but it is by far the best solution to the problem that you describe.
You can use a simple javascript redirect code such as the one below to redirect the user.
<script type="text/javascript">
<!--
window.location = "http://www.example.com/";
//-->
</script>
Are you hosting these servers in your own data center, or are you purchasing hosting? Our corporate site is hosted on multiple servers in our data center. We use load balancers to route traffic to different server farms based upon the URL. So
http://www.foo.com/assets/* might route to a farm of Apache HTTP servers that serve nothing but image files while
http://www.foo.com/apps/* might route to a farm of JEE application servers and
http://www.foo.com/services/* might route to a farm of servers especially designed to host web services and
http://www.foo.com/blog/* might route to a farm of servers that handle nothing but WordPress.
Works great... if you have all of this at your disposal. If you don't, then check out mod_proxy like Matt said (which we used before we bought load balancers).
blog.example.com
blog.example.com is easiest, since you can simply point it to a different IP address.
That is not what I want for a project I'm working on.
example.com/blog
Instead I use Apache mod_proxy to point /blog to another server. Apache docs here.
This worked well:
ProxyPass /blog http://blog.example.com/
ProxyPassReverse /blog http://blog.example.com/
But only after the proxy modules were loaded correctly:
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_html_module /usr/lib/apache2/modules/mod_proxy_html.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
Notes
Because of CloudFlare I also had to host the blog from a different hostname, not *.example.com.
I added Disallow: / to my blog.example.com/robots.txt. Like this search engines will not start indexing in two locations. And search engines will simply ignore blog/robots.txt.
Related
Lets say for example that I have a CMS installed on a domain: mycms.com
With Joomla or Wordpress on a LAMP environment (Linux, Apache, Mysql, PHP), lets say that it uses Cpanel.
And I have a page like for example mycms.com/mycategory wich links for different internal post/articles.
mycms.com/mycategory/post-1
mycms.com/mycategory/post-2
Now I have another domain: myotherdomain.com
And I want to setup this domain for that page (mycms.com/mycategory) In a way that every internal page also responds to that, example:
myotherdomain.com/post-1
myotherdomain.com/post-2
Notice, its not a simple redirect using PHP header() or JS, I want that myotherdomain.com to stay visible on browser address.
My question, this is possible? And its possible to do this without a dedicated server with SSH access? How I may do this? Editing my .htaccess?
Yes, you can. As you say, it's not a simple redirect, but it's a Proxy redirect. You can solve such problems at any preceding reverse proxy or immediately in Apache with mod_rewrite's proxy flag (it is [P]).
If you don't need any special pattern matching, you can even use PorxyPass:
ProxyPass "/post/" "https://mycms.com/mycategory/post/"
I am having issues with trying to get a WordPress Multisite (using subdomains) running on nginx.
Here is my ideal set-up:
domain.com
sub1.domain.com
sub2.domain.com
sub3.domain.com
Any requests to www.domain.com should be 301'd to domain.com (my understanding is that WordPress strips out www anyways?)
I am not wanting to access any of the subdomains by any other means, e.g domain2.com would direct a user to sub2.domain.com - this isn't what I want.
I have followed this DigitalOcean tutorial and everything has worked fine with regular WordPress installs.
My local hosts file is set up as follows:
XXX.XXX.XXX.XXX domain.com
XXX.XXX.XXX.XXX sub1.domain.com
etc...
My issue is that whenever I attempt to visit either domain.com or sub*.domain.com, I am redirected to a completely different site on my server, the one which just so happens to be the top of the list in sites-enabled. On closer inspect, when checking the Network tab in Chrome, I can see that my request for domain.com or sub*.domain.com is 301 redirected to the aforementioned unrelated site.
I have flushed my local Chrome cache, am constantly using Incognito mode and I just cannot shake this redirect. I'm even using Firefox as I rarely use it so wouldn't expect any caching whatsoever for domain.com
I may be completely off the mark here and it could be nothing to do with the browser at all but rather the server and nginx configuration. Something is forcing a 301 and I don't know what.
It seems that this plugin comes up a lot in discussion but as far as I can tell, this is only applicable when wanting to map a regular domain to a subdomain, which isn't what I want.
Can anyone please offer any advice/solutions as to how I can configure so everything is routed correctly? My local environment runs a LAMP stack so I have had this working and I have altered the wp-config.php file to reflect the new 'live' domain (remember, I have not configured DNS, I have just hacked around in etc/hosts.
Any help much appreciated as always :)
The only thing that avoids your request to be served by the "fallback", default vhost (that is, the "first" there) is the server_name directive.
Just by specifying location blocks in multiple server blocks with the same (or no) server_name won't make them magically match.
You can however use regular expression server names.
See here for how.
For the specific case with only a single domain, you can use
server_name *.whatever.com;
then match location with return 301 http://whatever.com; for subdomains only. That way you will not need regular expression server names.
Note that you should have server_name for the default server, like
server_name "_";
So in the end I decided to build the multisite from scratch in my nginx environment as opposed to trying to take what worked in Apache and re-configure for nginx. As far as I can tell, I had updated everything that you would expect to have to do so from Apache to nginx as well as updating local domains to live ones in the database and wp-config.
While this approach didn't strictly 'fix' my issue, I do feel like I've learned a valuable lesson here - sometimes starting from scratch is better than trying to make something fit!
I have a server that host a variety of asp.net sites on a IIS7 server.
A few of those sites have wordpress blogs in a folder called blog (which is obviously written in PHP). Due to security issues, we need to move those wordpress blogs to a linux server.
So instead of http://www.domainname.com/blog we now have http://blog.domainname.com/ which has the blog url.
The only problem is, due to SEO reasons, we need the blog to be on the same domain as the main site (which is written in ASP.NET).
My question is, is there a way to do a url rewrite so that if someone types in a wordpress link, similar to this:
http://www.domainname.com/blog/index.php/archives/category/mycategory
Can I use a web config URL rewrite to have the above typed in URL actually point to
http://blog.domainname.com/index.php/archives/category/banking
I can't do any sort of redirect. It has to be a rewrite, I've tried righting one myself but have been unable to. The subdomain is the part of the rewrite I can't get past.
Has anyone tried to do this before?
Is there some better way I go about this if not.
Keep in mind the blog and the asp.net site cannot be on the same server due to security reasons, but they must keep the same domain name.
You can't just do a rewrite as the URL you want to rewrite to is on another domain / website. Rewrites only work on the same website.
You have to setup IIS as a reverse proxy server with the ARR module. In combination with the URL rewrite module you will be able to invisibly forward all requests for http://www.domainname.com/blog/* to http://blog.domainname.com/*.
Also note that you will have to setup outbound rewriting in order to change back the URL's that are generated by Wordpress (from http://blog.domainname.com/* back to http://www.domainname.com/blog/*).
See for an example this tutorial: Reverse Proxy with URL Rewrite v2 and Application Request Routing.
I would like to migrate a site, but the new URL's are completely different from the old URL's. I do not want to break my old sites links that are out there on the web. Is there a way to extract all the links from a site so I can generate a redirect table (I will probably put the redirects on the web server level)? The old is on ASP.NET with SQL server 2008 by the way. Am open to crawling the site or mining the SQL database, but need some help or advice.
You could use IIS Seo Optimalization Toolkit for that. http://www.iis.net/download/seotoolkit
With that tool you can spider the entire website. Then when the report finishes, go to Content -> Host summary and double click the host of the website. There you have a complete list of all spedered URL's.
And ofcourse, when you have these url's, you can make URL rewrite of routing mechanisms available to 301 to the right content on the new website.
The best way is to actually put a 301 redirect to notify all engines that your URL's have permanently moved Search for 301 in this http response code documentation for more info on 301. That is if I am understanding your problem (that you want links from other sites and searches and whatnot to realize that your site moved?).
It doesn't sound like you're running Apache. However, Apache has an available module called mod_rewrite. There may be a similar module for other web servers.
mod_rewrite allows you to do exactly what you are describing.
Perhaps with litle js magic if works for you
What I want to do is take traffic that is going to shop.mywebsite.com and redirect or rewrite (I'm not sure of the terminology) the domain to be www.mywebsite.com/shop. Both shop.* and www.* are separate web applications (nopCommerce and Umbraco respectively) that don't seem to cooperate when I've tried to nest them. Both applications are in a Server 2008 R2/IIS 7.5 environment.
I've searched around stackoverflow and what I've found is a lot of answers to mapping the other direction (ie subfolder to a subdomain) but that's not what I'm looking for as far as I understand the problem.
The end goal is to combine the SEO reputation of the shop subdomain into the www subdomain. I readily admit that I might have this all backwards and am willing to try any suggestions I'm offered.
Thanks.
I think you are looking for URL rewriting.
URL rewriting is the process of
intercepting an incoming Web request
and redirecting the request to a
different resource. When performing
URL rewriting, typically the URL being
requested is checked and, based on its
value, the request is redirected to a
different URL
EDIT:
You may also want to check URL Rewrite Extension from microsoft, it will fix common SEO problems that your site might have.