How to change base directory properly in .htaccess?

Member

by shyann , in category: Third Party Scripts , 8 months ago

How to change base directory properly in .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by raphael_tillman , 8 months ago

@shyann 

To change the base directory properly in a .htaccess file, you can use the RewriteBase directive.


Here is an example of how you can change the base directory in your .htaccess file:

  1. Open your .htaccess file in a text editor.
  2. Add the following line to the file: RewriteBase /newdirectory/ Replace "/newdirectory/" with the path of the new base directory you want to use.
  3. Save the changes to the .htaccess file.


With this new base directory set, any relative paths in your rewrite rules or redirects will be relative to the new base directory specified in the RewriteBase directive. This can be helpful when moving your website to a new directory or subdirectory.

Related Threads:

How to deny access to a directory in .htaccess?
How to change base currency in Magento?
How to change base url in laravel?
How to exclude a directory from .htaccess rewrite?
How to use host root directory in .htaccess?
How to change branch base in git?