

It basically helps you set the beginning of all target relative paths for rewrite rules mentioned in your. In this article, we have learnt what is RewriteBase and how to use. # It can be "All", "None", or any combination of the keywords:Īlso read : Apache File Permissions Best Practices # AllowOverride controls what directives may be placed in.

If you don’t find this line, add it afresh.Īlso look for the following Directory tag and change AllowOverride from None to All. Uncomment it by removing # at its beginning. #LoadModule rewrite_module modules/mod_rewrite.so Open Apache configuration file in a text editor. Open terminal and run the following command to enable mod_rewrite $ sudo a2enmod rewrite Open terminal and run the following commands to enable mod_rewrite, depending on your Linux system. Otherwise here are the steps to do it.Īlso read : How to Prevent SQL Injection in Apache/PHP

Please make sure you have enabled mod_rewrite in Apache server before using RewriteBase directive. htaccess configuration with RewriteBase & RewriteRule rule. htaccess file, that contains this rule, is located in /folder then Apache will redirect all requests from /folder/product to / data/about This statement will redirect all requests from /product to /data/about

If you have the following RewriteRule after the above statement. Let us say you have the following RewriteBase rule. This path is appended at the beginning of every destination relative path used in RewriteRule. In the above statement you need to mention relative path for RewriteBase. Here is the syntax of RewriteBase directive RewriteBase /relative/path Then Apache will redirect all requests from /folder/sub-dir1 to /folder/sub-dir2 If you have the following RewriteRule, RewriteRule /sub-dir1 /sub-dir2 htaccess file is located at /folder, then all relative paths in. htaccess file are with respect to the location of. For example, if you want to move all these URLs to new directory, then just change the RewriteBase value without changing any Rewrite rule that follow.Īlso read : How to Change Apache Log Levelīy default, all relative paths used in. It is useful if you have numerous Rewrite rules in your. htaccess file where RewriteBase directive is mentioned. Also it is applicable only for rewrite rules mentioned in the same. Its value is used in the target/destination path mentioned in rewrite rules in. RewriteBase directive allows you to easily set the beginning of all relative paths used in. In this article, we will look at what is RewriteBase and how it works, with examples. RewriteBase is a useful server directive available for Apache web server that allows you to easily update numerous rewrite rules at one go.
