Learn the basics of mod-rewrite | htaccess tutorial step by step for beginners

April 15, 2021 2 Comments

htaccess has always been a confusing topic for all Apache users especially for newbies who are learning to write RewriteRules to modify URLs via an htaccess file. The reason why some people find it confusing is because the Apache mod-rewrite documentation is hard to follow and there are no easy to follow htaccess step by …

Converting a long query string URL to short and SEO friendly using RewriteRule in htaccess

April 3, 2021 0 Comments

In this post you will learn how to shorten a long URL with very simple steps using RewriteRule directive in an htaccess file. We are going to change a really long URL that is hard to type , hard to remember and not good for SEO in this article. We have a URL of the …

IMG, JS, CSS and other files failed to load after using RewriteRule in htaccess?

March 30, 2021 0 Comments

One of the most common issue every mod-rewrite users encounter while using RewriteRule directive to shorten their URLs is the IMG, CSS , JS and other relative resources failing to load. If you are using RewriteRules to rewrite your URLs then you may sometimes face this kind of issue . This is a normal behavior. …

How to set an ENV (Environment) variable using RewriteRule in htaccess

March 27, 2021 0 Comments

There are different ways and directives to set an environment variable on Apache server through a htaccess file. One of the most common and the easiest way to set an Environment variable is by using a RewriteRule directive. It’s the easiest method because you can rewrite your domain requests based on env and also you …

Redirect a domain to another domain without changing URL with htaccess

March 26, 2021 0 Comments

In this post I will show you how to write a rule to redirect your domain to an external domain without changing the URL in browser address bar . Redirect domain without changing the URL . You need to enable proxy module on your apache web server in order to map/redirect (internally) your domain to …

Map a subdomain to subfolder with htaccess

March 25, 2021 0 Comments

With an htaccess rewrite ,it is quite possible to map your subdomain to subfolder if its not already pointing there. Suppose, you just created a new subdomain named bar.example.com and its currently pointing to you root directory , you can simply use a RewriteRule to map it to a new folder. This article will teach …

http to https and enforce www in one 301 redirect on htaccess

March 23, 2021 0 Comments

If you are looking for an htaccess RewriteRule that enforces www and https in one redirection and without creating multiple redirects then you have come to the right place. On this article I am going post a 100 percent working rule that you can just copy and paste to your htaccess file. Here is the …

Mod-rewrite NE flag uses and code examples

March 22, 2021 0 Comments

In this article we will learn about mod-rewrite NEflag. What this flag is used for and why we should use it all these frequently asked questions are answered in this article. NE stands for NoEscape We use this flag in RewriteRule to tell the engine not to escape special characters like # , & .. …

Show a custom error text using ErrorDocument in htaccess

March 21, 2021 0 Comments

With ErrorDocument directive it is also possible to show a custom error text instead of redirecting the request to error page. You can use your own error text message that will be displayed to broken requests on the server. Here is an example : ErrorDocument 404 “Sorry the page could not be found” This will …

5 awesome htaccess rules you can just copy and paste

March 21, 2021 0 Comments

In this post you will find 5 mod-rewrite rules that you can just copy and paste to your htaccess file. htaccess copy paste rules with code examples. All the rules provided here are tested and works perfectly fine in an htaccess file. If you are one of those guys who loves to copy and paste …