Prevent hotlinking using htaccess

January 20, 2020 0 Comments

Hotlink protection using htaccess One of the most beneficial use of htaccess is to prevent hotlinking of images , videos and other documents on your website. You can use htaccess to prevent hotlinking of your media and other documents. What is hotlinking? It means to display an image on a website by linking to the …

convert a long URL into short using RewriteRule in htaccess

November 20, 2019 0 Comments

URL rewriting on Apache server is one of the most easiest and convenient way to shorten a long URL to make it short and search engine friendly. Apache server supports server.config and .htaccess files . Not all web hosting providers allow you to access the main server.config file and in that case the only option …

RewriteRule vs Redirect directive runtime behavior explained with examples

October 31, 2019 0 Comments

What is RewriteRule RewriteRule directive is used to rewite/redirect URLs on Apache server. To convert a longer URL path into shorter one we use RewriteRule directive which is part of Apache mod-rewite (Rewrite Module) . The following is the basic syntax of RewriteRule directive: RewriteRule newPath oldPath [flags] Redirect directive Redirect directive is part of …

Can we redirect fragment/hash URLs using htaccess RewriteRule?

October 26, 2019 0 Comments

I often see users struggling with their RewriteRule to redirect fragment URLs. Fragment is something that the server doesn’t receive meaning that a URL containing #path  can not be redirected using htaccess or any other server side redirection methods. Fragment usually appers at the end of the URL and starts with a “#” character. Anything …

Time based URL rewriting Apache htaccess

October 19, 2019 0 Comments

Time based URL rewriting on Apache With mod-rewite you can rewite or redirect your URLs based on server date and time logic. You can redirect your visitors to a specific page or URL destination using this date/time logic. In this post, we will learn how to apply date/time conditions to RewriteRule directive with some code …

How to know whether mod-rewite is enabled on Apache server – AmitOverflow blog

October 8, 2019 0 Comments

How to check whether mod-rewite is enabled on Apache server mod-rewite is a URL rewriting module provided by Apache. We use this module to rewite or beautify our site URLs. Although all web hosting service providers have pre-installed this module but in some cases you must enable it yourself in order to use RewriteRules in …

Deny access to multiple ip addresses using RewriteRule in htaccess

June 26, 2019 0 Comments

With a RewriteRule directive you can deny access to a specific IP address or multiple ip addresses at ones. If you need to deny access to a visitor IP address you can use a RewriteRule directive in htaccess file that checks the visitor IP address and blocks access to that address. Blocking IP addressess using …

How to redirect a URL with Query String apache htaccess

June 21, 2019 0 Comments

Redirect URL query string using htaccess In this post we will learn how to redirect a URL with query string using RewriteRule directive in htaccess. Query string represents URL part that is after ? character in URL. A URL with query string looks like the following example URL:http://example.com/file.php?q=foo&lang=en As you can see the above example …

Enforce https and www in a single htaccess rule – AmitOverflow blog

June 18, 2019 0 Comments

It is quite possible to redirect http and non www requests to https and www with one single redirect using a RewriteRule in htaccess. Assuming, you want your site visitors to always redirect to https://www version of your site regardless of they come by http or non-www you can use a single redirect Rule that …

Set env variable in htaccess – Create Apache Environment variable viahtaccess

June 13, 2019 0 Comments

You can set an environment variable using your htaccess file. There are two ways to do this via an htaccess. RewriteRule SetEnv directive Setting env variable via RewriteRule To set env variable through a RewriteRule, you need to use E flag. Syntex for the E flag is as follows E=variable:value . The following is basic …