RedditPP Mascot

RedditPP

r/webhosting • … • u/brakhage

Not sure what this is called - I want to send URL to file path in Apache

I just started using Cpanel + Apache after months of using nginx form the command line - which got too frustrating for a newbie, hence cpanel.

Right now,

https://example.com/

pulls up the content from /home/user/public_html/

But I have a lot of sites, and I don't want all of their URLs to based on the file paths from that directory. So, for example, I'd like to send, say

https://example.com/website2

to

/home/user/public_html/subfolder/anothersubfolder/website2

and

https://example.com/website3

to

/home/user/public_html/totallydifferentpath/website3

I can do it with RewriteRules in the .htaccess file, but that just enables the user to put in /website2, but as soon as they get there, their URL bar reads /subfolder/anothersubfolder/website2

In nginx I was doing this in the config files like so:

location ^~ /website2 { alias /subfolder/anothersubfolder/website2; index index.html; }

How do I do this in apache/.htaccess? Or, as I know this is a very basic question - what is this called?

(When I search for "cpanel apache alias" I get...I'm not sure what, but it doesn't seem to be what I'm looking for.)

— 0