mod_rewrite vs virtualhost
Hello! I'm a bit newbie, running a VPS with cPanel. Need a little guidance, please.
I have a folder "public_html/site"
It contains an "index.php" file that expects a parameter to know which database to access, and serve a little response.
There are 2 databases:
"web1"
"web2"
What I want to achieve is to be able to write "myserver.site/web1" or "myserver.site/web2" in the browser,
and get it pointed to the folder "/site" while receiving "web1" or "web2" as the parameter needed by index.php
- Can I solve this by using apache's mod_rewrite? Or am I forced to use a different alternative like virtualhost?
- Will this approach be still compatible even if tomorrow the people in charge of "web2" buy a domain name and need to access from it ?
- Do you foresaw some hidden danger I'm ignoring because I'm a beginner?
I hope mod_rewrite is enough.. I don't feel confident setting up the virtualhost.. But I'm willing to google and learn.
Thanks a lot in advance !!
Lionel
-
Hey there! Yes, I would expect that using .htaccess would be just fine. You wouldn't be able to edit the Apache vhost directly anyway, as we require that you use Include files to adjust that file:
https://docs.cpanel.net/ea4/apache/modify-apache-virtual-hosts-with-include-files/
While I don't have any .htaccess code I can provide to help with this, just don't edit between the auto-generated PHP handler section and you'll be just fine.
0 -
Thank you a lot ! Also the link was useful !!!
1
Please sign in to leave a comment.
Comments
2 comments