How to change base directory properly in .htaccess?

Member

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

How to change base directory properly in .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by raphael_tillman , 4 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.