2

Basically, I want to host a website through a CDN. My website currently contains a few URL's with parameters, eg.

http://example.com/articles.html?start=20

I want my website to look like the website used to look (eg. it should respond with the same page as originally when the user visits the parameter URL).

Seeing as this is a CDN host, I cannot use .htaccess etc. which is why I'm asking the question here rather than resolve it myself.

Is there any way to name the file (including the parameter) so it responds to the URL above?

EDIT: Spiders need to be able to properly crawl the content, so JS won't do the trick here.

J. Doe
  • 677
  • 7
  • 20
  • What kind of CDN is it? Often a CDN is just a caching server in front of your actual server, which will relay initial requests to your origin server. So… nothing much needs to change. – deceze Oct 17 '16 at 15:37
  • Possible duplicate of [How can I get query string values in JavaScript?](http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript) – dashdashzako Oct 17 '16 at 15:38
  • You should parse query parameters and use them to customize the layout of your site. It can be done with javascript. – dashdashzako Oct 17 '16 at 15:40
  • @damienc So… you're suggesting to rewrite the entire site to move from server-side templating to client-side templating? Hmmmm… – deceze Oct 17 '16 at 15:42
  • `My website currently contains a few URL's`. This doesn't look like the entire site, does it? – dashdashzako Oct 17 '16 at 15:44
  • @deceze The CDN is essentially a static file host - think in terms of dropbox. So my files WILL be hosted on the CDN. – J. Doe Oct 17 '16 at 15:53
  • @damienc Spiders need to be able to parse all the content, therefore I cannot dynamically generate the content through JS. – J. Doe Oct 17 '16 at 15:53
  • Josef's answer looks fine. If you have the opportunity to rewrite your current urls to something like `http://example.com/articles/page/1`, this could avoid the CDN to parse query params by exactly matching your dynamic urls. – dashdashzako Oct 17 '16 at 16:02

1 Answers1

3

Try name your files exactly as URL you desire, for example articles.html?start=20. If the CDN server is not configured to handle it and you cannot change the configuration, you are out of luck.

(I assume the CDN server is plain file hosting without any server-side scripting.)

If your URLs are not publicly known yet (so you can change them), you can use a static website generator. URLs will look different (no ?), but it will work.

Josef Kufner
  • 2,851
  • 22
  • 28
  • Hmm initially I didn't think I could use '?' in the file names. However this might be enabled after all. I'll take a look at it. – J. Doe Oct 17 '16 at 15:55
  • You [can't on Windows](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx), but Linux (and others) allow anything except `'\0'` and `'/'`. – Josef Kufner Oct 17 '16 at 20:49