Wordpress plugin for independent self-hosted CDN - cookies

I'm trying to set a cookieless subdomain to serve static content of my wordpress website. So I've tried self-hosted CDN solutions using WP SuperCache or W3 Total Cache plugin.
My wordpress is on the domain aljazair24.com and my CDN domain is static1.aljazair24.com. The domain and subdomain point to the same apache directory (/home/username/public_html).
Although WP SuperCache and W3TC plugins allow to set cookie domain to aljazair24.com, the subdomain static1.aljazair24.com still sends cookies to browsers...
I've tried to set cookie domain to www.aljazair24.com in order to avoid this but it doesn't work, since all www urls are redirected to non-www ones...
I was desperately looking for any WP plugin allowing to make "real" mirror resources, all this in order to avoid any interference at htaccess level. Unfortunately I didn't find anything ...
What should I do to make subdomain static1.aljazair24.com cookie-free ?
Page speed tests using YSlow
Grade F on Use cookie-free domains
There are 82 components that are not cookie-free
http://static1.aljazair24.com/wp-content/plugins/ajax-load-more/core/js/ajax-load-more.min.js
http://static1.aljazair24.com/wp-content/themes/aljazair/inc/js/flexslider.min.js
http://static1.aljazair24.com/wp-content/plugins/wysija-newsletters/js/validate/languages/jquery.validationEngine-ar.js
http://static1.aljazair24.com/wp-content/plugins/wysija-newsletters/js/front-subscribers.js
...

Have you tried Cloudflare? Most hosting providers have a built in extension and you dont have go through plugins like WP SuperCache or W3 Total Cache.

Related

Multiple netlify static sites served under a single cloudfront domain path

I have multiple netlify static sites that I want to serve in their entirety under a path of a cloudfront domain. However, resources that don't reside at the root of the netlify app are not being served (raise a 404)
i.e.
https://netlify1-abcd123.netlify.app/
/
/page1
/page1/subpage1
/page2
/images/logo.png
/stylesheets/styles.css
https://netlify2-defg456.netlify.app/
/
/netlify2-page1
/netlify2-page1/subpage1
/netlify2-page2
/netlify2-images/logo.png
/netlify2-stylesheets/styles.css
and I want these to be served under www.mydomain.com/netflify1 and www.mydomain.com/netlify2. The root of www.mydomain.com is currently served via an S3 static site.
I have configured rewrite rules in netlify.toml for each site (changing as appropriate to netlify2) as below:
[[redirects]]
from = "/netlify1/*"
to = "https://netlify1-abcd123.netlify.app/:splat"
status = 200
force = true
...and then added an Origin to Cloudfront which has the Origin Domain Name of https://netlify1-abcd123.netlify.app/ - all other Origin settings are the defaults.
I've then configured a Behaviour with a Path Pattern netlify1 that points to the netlify1 origin. Note that I cannot use the Default behaviour as the main index of www.mydomain.com is served via a static site hosted on S3.
This all works perfectly fine when serving the root / of my netlify app. I can navigate to www.mydomain.com/netlify1 and see the home page of my netlify app. However, anything that is not on the / of netlify doesn't get served.
I can see from the developer tools that a request is being made to www.mydomain.com/images/logo.png and www.mydomain.com/stylesheets/styles.css when trying to load the images and the styles. This returns a 404 because (I presume) they are not getting picked up by any Cloudfront Behaviour or Netlify rewrite rules.
So my question is. How can I make images, stylesheets and any page not on the root of the netlify apps work correctly? I can make it work by manually added every single potential path as a Behaviour on Cloudfront (i.e. configure a Behaviour with a Path Pattern of /images/* to point to the netlify1 Origin) - but that doesn't seem scalable or even correct.
I don't know whether I need to somehow rewrite all my URLs on the netlify app during building so that they become /netlify1/images and /netlify/page1 rather than /images and /page1 (the netlify apps are docs built with Sphinx docs), or whether this is something that needs to be handled via a Rewrite Rule in Lambda#Edge. I'm completely stumped.

What is the correct way to do a redirection from www. to the naked domain (Server or App or Domain Provider)?

I currently have an app that works with both www.domain.com and domain.com. Considering that this seems to be bad for SEO, I want it to always redirect to the naked domain.
My app works in this way:
Server: Google Cloud Platform (App engine)
App: Django
Domain provider: Godaddy
As I have researched the redirection can be done from any of these 3 options. So I want to ask: What is the best option and why?
I tested to do the redirection with GoDaddy on App Engine (An A record for www pointing to #) but when I set my custom domain in App Engine, I noticed that for the www.domain a C Record pointed to ghs.googlehosted.com setting was required in the app engine panel, I omitted that in order to do the redirection in GoDaddy, but the app wouldn't load when visiting from www.domain, a 404 error appeared (Also tried by omitting the addition of the www.domain altogether in app engine settings) So I wasn't able to accomplish this in the same fashion than an app that is hosted in a single server.
I think the easiest way would be to handle this inside the app itself like this site mentions

Use GitHub Pages domain for a Netlify site

I would like to build a Netlify (or perhaps a Zeit Now) site.
Despite the extra feaures of Netlify and Zeit, I find GitHub pages foo.github.io domain name more catchy than foo.netlify.com.
I see that GitHub allows to use a custom domain, so that you can point your example.com domain to your GitHub pages.
Is the reverse possible? That is, I'd like using foo.github.io as the domain name for the site stored at foo.netlify.com.
Because you do now own the domain github.io (and by extension, the domain foo.github.io) this is not feasible.
To add a custom domain to Netlify, you need to point a CNAME to your-random-string-url.netlify.com (via DNS).
GitHub allows you to redirect a domain, but this will rewrite the url in the browser - which is not what you want.
I would recommend investing in your own domain name, and point it to whichever service you end up using. You will then not be locked into any service in the future.

Static site with netlify + Django on the same url

Let's assume I own the domain:
foobar.com/
I want to use Netlify for my static pages like
foobar.com/features/
foobar.com/pricing/
foobar.com/imprint/
etc.
But I also have a Django application on a seperate server on AWS that has nothing to do with the static sites served by Netlify.
My Django has urls like
foobar.com/login/
foobar.com/dashboard/
etc.
Is it possible to use Netlify for a few static pages and my Django application for other pages?
I don't know how start or if this is event possible.
It will depend on how your Django apps handle the target, but you could use rewrites on Netlify using the HTTP status code 200 with a redirect rule (rewrite).
If the API supports standard HTTP caching mechanisms like Etags or Last-Modified headers, the responses will even get cached by CDN nodes.
Have DNS set foobar.com to the Netlify site.
Decide the domain for the Django site on AWS. (proxy.foobar.com)
Setup _redirects at the root of the Netlify site to use Proxy (rewrites) on Netlify
/login/* https://proxy.foobar.com/login/:splat 200
/dashboard/* https://proxy.foobar.com/dashboard/:splat 200
Note: This is how you can incrementally switch a site over to Netlify without having to refactor a site all at once.
When you set a DNS record (e.g. an A record), you can point foobar.com to your AWS server or netlify, but not both.
Perhaps you can put the sites on different domains, for example dashboard.foobar.com for your Django site.
You could then configure netlify to redirect foobar.com/dashboard/ to dashboard.foobar.com/dashboard/
No, you can't have a foobar.com point to two different servers. You'll have to use subdomains, e.g.:
static.foobar.com -> DNS entry for Netlify
app.foobar.com -> DNS entry for your Django server
or, what you often see, is:
foobar.com and www.foobar.com -> DNS pointing to your main website (Netlify)
api.foobar.com and app.foobar.com -> DNS pointing to your Django app

How to redirect non-www domain.com to www domain.com(WordPress blog) in AWS Route 53?

I have my non-www domain.com with GoDaddy and my WordPress Blog is hosted in AWS EC2. I'm using Route 53 to handle DNS requests. The existing solution for my question, seen in many places(including SOF) is to create two S3 buckets in the name of non-www domain and www domain for redirection of static websites. This is not my case.
I've my WordPress installed in EC2 and not using S3 for holding my Data. I hope this is not a static website and cannot follow the general solutions available.
I tried the following solution around and did not work
I tried changing the C-NAME record to www.domain.com but it did not worked.
I tried domain forward feature available with GoDaddy.com and didn't work.
I tried modifying .htaccess file and that too didn't work.
This is what my record sets in Route 53 look like
Name Type Value TTL
------ ----- ----- ----
domain.com. A xx.xx.xxx.xxx (EIP) 300
domain.com. MX 1 ASPMX.L.GOOGLE.COM 3600
5 ALT1.ASPMX.L.GOOGLE.COM
5 ALT2.ASPMX.L.GOOGLE.COM
10 ALT3.ASPMX.L.GOOGLE.COM
10 ALT4.ASPMX.L.GOOGLE.COM
domain.com. NS ns-27.awsdns-03.com. 172800
ns-1190.awsdns-20.org.
ns-2028.awsdns-61.co.uk.
ns-855.awsdns-42.net.
domain.com. SOA xxxxxxxxx 900
How can I redirect my domain.com to www.domain.com?
I was hesitant to post my comment as an answer because there are a gazillion ways to setup and configure Wordpress it seems. Anyway, to keep in the spirit of keeping this question in the amazon-web-services tag I ran a test case deploying from the AWS Wordpress Cloudformation template. I'm not sure if this is how you actually installed Wordpress but here is one way to redirect:
Make sure that your Cloudformation template completes successfully.
Here is what my Hosted Zone looked like - I have not added A records yet.
Get the instance IP address. Note that in this example I did not setup an Elastic IP. Since I knew that I would not need to stop the instance temporarily I opted to just stick with the automatically assigned, random pubic IP.
Next I made an A record for the domain apex of that IP and then an A record for www. I also changed the TTL to 60 seconds.
Once DNS propagation completed I tried accessing my domain name. As you can see, the AWS Cloudformation Wordpress installation defaults to a different path and URL.
Using the URL, http://example.com/wordpress did the trick.
I didn't go through the steps but when you go to http://example.com/wordpress it starts a setup screen. Enter all the information like DB name and password, etc. and then login to the admin panel. Once you go through all of that you go to the General settings screen. This is where your configuration will probably be different but for mine, the URLs were listed as http://example.com/wordpress. I simply changed these URLs to http://www.example.com/wordpress. (As an aside, I also tried changing and saving the permalink section to generate an .htaccess file but one was not generated due to the inability to write to the file. I tried making my own but I kept running into "too many redirect" messages so this might not be a route you want to take depending on your install.)
You will need to make a change in the index.php file. For my installation it was located at /var/www/html/wordpress/index.php. Make sure to make a copy before changing it. I simply added /wordpress/ in front of wp-blog-header.php. Again, this install puts the Wordpress files in the directory /wordpress - your install will probably be different.
Next you need to copy that modified index.php file to /var/www/html/ and then restart the httpd service.
To test the change I cleared out my DNS cache and opened up the network section of developer tools in Chrome.
I then opened a new tab (have to open developer tools again) and then typed in the naked domain name.
As you can see, the URL redirected to www.example.com with a 301 permanent redirect.
I'll through another suggestion out here while I'm at it. You can use the free version of Cloudflare to just do the redirect for you. Cloudflare offers a bunch of other free and useful services like CDN so if you don't mind depending on a 3rd party service (a reputable one by the way) it might be easier with more value add. As I highlighted in the screenshot however, note that if you use forwarding you cannot use some of the other advanced rule sets.
Anyway, I hope this helps!