更改 HTTP 请求的基本目录 -- CPanel
我有一个托管在服务器上的 php 网站。我使用 CPanel 来管理它。 public_html 可以说以下目录结构
public_html
- dir1
- dir2
- dir3
- ....other files.....
- website2home
现在我尝试将 website2home 作为我网站的基本目录,但是 website2home 内的文件使用 public_html 文件夹中的一些文件和来自 public_html 文件夹的一些文件在其自身之内。
问题
当我将域名分配给website2home时,它不会从public_html
文件夹中读取文件(事实上,public_html文件夹不可见) )并显示一些 php 警告和一些 404 未找到错误。但是假设原始网站的域名是 www.aaa.com
,那么如果我使用 www.aaa.com/website2home
访问 website2home
> 一切正常。
所以我的问题...
有什么方法可以设置基本目录,以便我的 website2home 获取所有文件和正确的文件,而无需替换 php 代码中的数百个文件路径?
考虑到我不想修改网站的源文件,请回答。
I have a php websites hosted on a server. I use CPanel to manage it. public_html has lets say following directory structure
public_html
- dir1
- dir2
- dir3
- ....other files.....
- website2home
Now I am trying to make website2home as the base directory of my website, but files inside website2home use some files from public_html folder and some files from within itself.
THE PROBLEM
When I assign a domain name to website2home, It does not reads the files from public_html
folder (in fact, public_html folder is not visible) and shows some php warnings and some 404 not found errors. But lets say the domain name for original website is www.aaa.com
, then if I access website2home
by using www.aaa.com/website2home
all works fine.
So My Question...
Is there any way to set the base directory, so that my website2home fetches all files and correct files without replacing hundreds of filepaths in php code?
Please answer considering that I don't want to modify source files of website.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您正在寻找某种 .htaccess 配置。例如,您可以将您的 website2home 文件夹设置为 www.aaa.com 域的基本文件夹,然后使用 .htaccess 将某些文件访问重定向到其他文件夹,如下所示..
看看 mod_rewrite 文档
编辑:如果出于某种原因, 这../ 重定向不起作用,您始终可以将所有文件重定向到伪索引 PHP 页面。例如:
然后,在您的 PHP 索引页面中,您可以简单地将 PHP 文件加载到其他文件夹中:
I believe you are looking for some kind of .htaccess configuration. For instance, you may set your website2home folder as base folder for your www.aaa.com domain and then redirect some file access to other folders using .htaccess, something like this..
Have a look to mod_rewrite documentation
Edit: If, for some reason, the ../ redirection doesn't work, you always can redirect all your files to a pseudo-index PHP page. For instance:
And then, in your index PHP page you can simply load your PHP files in other folder: