1

I have a website set up with its own root directory in the common configuration:

mywebsite.com --> /path/www/mywebsite

And them pathnames on mywebsite get naturally mapped to their corresponding subdirectory:

mywebsite.com/folder_a/ --> /www/mywebsite/folder_a/
mywebsite.com/folder_b/ --> /www/mywebsite/folder_b/
mywebsite.com/folder_c/ --> /www/mywebsite/folder_c/
... and so on

I would like to change the location for one of such subdirectories, so I could do something similar to:

mywebsite.com/folder_a/ --> /www/mywebsite/folder_a/
mywebsite.com/folder_b/ --> /some_other_path_on_my_server/
mywebsite.com/folder_c/ --> /www/mywebsite/folder_c/
... and so on

Although I know I can solve this by using a symlink to the other path, I would prefer to have this explicitly set up on my .htaccess file.

Is this possible? And if so, how?

Ale Morales
  • 113
  • 3

1 Answers1

0

You can't do this with .htaccess alone since the file-path you are wanting to "rewrite" to is outside of the domains DocumentRoot.

In .htaccess (a directory context), the substitution string represents a URL-path, not a file-path.

You can do this if you have access to the server config (virtualhost). In a server or virtualhost context you can rewrite to an absolute file-path. However, if you have access to the server config then you would configure this as an Alias instead - you wouldn't use mod_rewrite.

MrWhite
  • 12,647
  • 4
  • 29
  • 41