How to remove traling slashes from URLs using RewriteRule | URL Rewriting Tips

February 20, 2020 0 Comments

Last Updated on April 14, 2021 by amitoverflow1 A slash , / character, that appears at the end of URL path is called a traling slash. A typical URL with traling slash looks something like the following: https://example.com/path/ A traling slash at the end of an existing directory prevents directory listing so its important to …

Rewrite /username/ to /user.php?user=username with RewriteRule htaccess |URL Rewriting Tips

February 20, 2020 0 Comments

Last Updated on April 15, 2021 by amitoverflow1 In this post post I will show you how to shorten a user URL on Apache server by htaccess. Assuming you have a long user URL that looks something like the following: /user.php?username=foobar And you want to shorten this URL to : /foobar The shorter version is …

Mod-rewrite NC (NoCase) flag | URL Rewriting Tips

February 18, 2020 0 Comments

Last Updated on April 14, 2021 by amitoverflow1 What is NC in mod-rewite? NC stands for NoCase and is a URL rewriting flag used on Apache server. We use NC to rewrite URLs in a case insensitive manner. With NC flag set in RewriteRule you can use both upper-case and lower-case in URL path matching …

Reditect domain using proxy P flag in htaccess

February 18, 2020 0 Comments

Last Updated on April 16, 2021 by amitoverflow1 Apache Proxy module “Apache Proxy module” also known as mod-proxy is a URL rewriting module provided by Apache. This module enables URL rewriting between domains hosted on two different servers. With mod-proxy enabled , you can redirect your domain to an external domain without changing the URL …

htaccess redirect users based on browser language | URL Rewriting Tips

February 17, 2020 0 Comments

Last Updated on April 14, 2021 by amitoverflow1 Redirect users based on browser language If you have a multilingual website that is available to users in the language that they understand, you can set an automatic redirect with htaccess that will redirect your users to the language version their browser is in. For example a …

A simple htaccess rule to block web crawlers and Http user agents | URL Rewriting Tips

February 15, 2020 0 Comments

Last Updated on April 16, 2021 by amitoverflow1 What is a web crawler? A Web crawler, also called a spider or spiderbot and often shortened to crawler, is a type of Internet bot that systematically browses the World Wide Web, typically for the purpose of Web indexing (web spidering). Search engines like google , yahoo …

Redirect 404 URIs to a different domain with htaccess | URL Rewriting Tips

February 11, 2020 0 Comments

Last Updated on April 15, 2021 by amitoverflow1 Redirect 404 URIs to a different domain with htaccess The following rule will redirect all 404 URIs from your site to http://example.com RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule .+ http://example.com/ [L,R] You can just copy and paste this rule to your htaccess in document root folder. This …

htaccess redirect http to https for Cloudflare users | URL Rewriting Tips

February 10, 2020 0 Comments

Last Updated on April 14, 2021 by amitoverflow1 Cloudflare http to https using RewriteRule Cloudflare has its own variable to check URL scheme. If you are using cloudflare then your normal htaccess http to https redirect can fail to work. One possible reason behind this is that cloudflare uses %{HTTP:CF-Visitor} variable to check the requested …

Is it possible to htaccess redirect https to http without a ssl certificate? | URL Rewriting Tips

February 5, 2020 0 Comments

Last Updated on April 17, 2021 by amitoverflow1 Redirect https to http using htaccess without a valid SSL certificate One of our blog reader recently asked whether they could redirect redirect https URLs to http for a domain that was indexed as https in search results but now the domain isn’t SSL enabled. The short …

Remove .html and php extension with htaccess RewriteRule | URL Rewriting Tips

February 4, 2020 0 Comments

Last Updated on April 15, 2021 by amitoverflow1 Remove php and html file extension from URLs using RewriteRule in htaccess In this post we will learn how to use RewriteRule directive to remove html and php file extensions from URLs. I know there are thousands of similar posts already indexed on the web but this …