Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Sunday, September 2, 2018

What is the maximum length of a URL in a browser?

Since the web runs on links, it is worth while to know the max length of a link : there is no limit at all in the specification. But, browsers will have limits.

The exact specification reads :

Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs.

(Source: http://www.faqs.org/rfcs/rfc2616.html)

However, Microsoft Internet Explorer only can handle around 2,000 characters. (Source: https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer)

More than that, a webpage whose url is 2,000 characters will take longer to load than one whose length is 20 characters. At the very least, because your computer needs to download 1,980 characters less.

In terms of networking, domain lookup times, or file lookup times, longer names similarly slow things down. Additionally, search engines dislike overly long URLs, so, if SEO is important, try to keep to a limit of 100 or fewer characters.

Monday, August 27, 2018

Using HTAccess to Redirect All Users (and POST data) to the Same URL

With the Apache .htaccess file, you can control a good number of things on your server.

If you turn on the RewriteEngine, you can have one URL example.com/123, always return the results of another URL, like example.com/index.php?id=123.

To do this, you need to have a .htaccess file in the base directory of your apache htdocs folder. It should start with this...

RewriteEngine On
RewriteBase /

And, it can redirect everyone to index.php with this...

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,NC,L]

You can change index.php to anything you like, of course. Then you can get the information about the original URL by using the $_POST parameters, which you can see with...

print_r($_POST);