使用新的 cpanel 帐户重写 php .htaccess

发布于 2024-08-16 23:45:16 字数 625 浏览 3 评论 0原文

我的 .htaccess 文件中有以下内容,我经常这样做是为了更清晰的 URL。我知道这有优点也有缺点,而且我想我已经找到了缺点。

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Options All -Indexes

我为此网站建立了一个新的 cPanel 帐户,因此 URL 如下所示:

http://www.example.com/~newuser/

...其中 example.com 是我的经销商帐户,newuser 是我的客户。

该网站加载正常,但当我单击链接 http://www.example.com/~newuser/about 时,出现以下错误:

请求的URL /home/newuser/public_html/about.php 在此服务器上找不到。

问题是,这正是我想要显示的文件,即文档根目录。有什么想法吗?

提前致谢。

I have the following in my .htaccess file, which I do often for cleaner URL's. There are pro's and cons to this I know and I think I've found a con.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Options All -Indexes

I've up a new cPanel account for this website so the URL looks like this:

http://www.example.com/~newuser/

...where example.com is my reseller account and newuser is my client.

The site loads fine but when I click a link http://www.example.com/~newuser/about I get the following error:

The requested URL
/home/newuser/public_html/about.php
was not found on this server.

The problem is, that's exactly the file I want it to display and that is the document root. Any ideas?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆夏时光 2024-08-23 23:45:16

RewriteCond 行之前,添加 RewriteBase 行,如下所示:

RewriteEngine on
RewriteBase /~newuser/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Options All -Indexes

Before your RewriteCond lines, add a RewriteBase line like so:

RewriteEngine on
RewriteBase /~newuser/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Options All -Indexes
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文