Score:1

Is is possible to change a path's root folder with .htaccess?

de flag

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?

Score:0
kz flag

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.

de flag
Thank you, I was afraid of it not being possible, but an answer is an answer nonetheless.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.