使用 htaccess 与 cPanel 临时 url 进行 url 重写

发布于 2024-12-04 01:02:04 字数 696 浏览 0 评论 0原文

我们准备推出一个新网站。所有开发都是在一个单独的子域(cli.company.com)上完成的,我们使用 htaccess 命令来获取干净的 url,这一切都工作正常。 HTACCESS 代码如下:

RewriteEngine on

RewriteRule ^page/([^/\.]+)/?$ page.php?page=$1 [L]
RewriteRule ^([^/\.]+)/?/([^/\.]+)/?$ page.php?theme=$1&pg=$2 [L]

RewriteRule ^([^/\.]+)/?$ page.php?theme=$1&pg=$1 [L]
RewriteRule ^([^/\.]+)/?/$ page.php?theme=$1&pg=$1 [L]

所以,一切都很好&在开发站点上运行良好。问题是我们现在准备切换到实时域,并且客户端有一个当前站点,因此我们同时移动托管。在我们的服务器上,域已设置并且所有文件都已准备就绪。 cPanel 为我们提供的临时 URL 如下所示:http://00.00.000.000/~cli/_clientsite.com/

该网站的主页在最终测试中显示得很好,因为它不依赖于 url 重写,但内部页面给出了 404 错误,我认为这是因为重写规则没有正确启动。

我只需要这个来进行测试,因为我们负担不起它的上线而不工作。有办法解决这个问题吗?

We have a new site ready to launch. all development has been done on a separate subdomain (cli.company.com) and we're using htaccess commands for clean urls, which is all working fine. The HTACCESS code is as follows:

RewriteEngine on

RewriteRule ^page/([^/\.]+)/?$ page.php?page=$1 [L]
RewriteRule ^([^/\.]+)/?/([^/\.]+)/?$ page.php?theme=$1&pg=$2 [L]

RewriteRule ^([^/\.]+)/?$ page.php?theme=$1&pg=$1 [L]
RewriteRule ^([^/\.]+)/?/$ page.php?theme=$1&pg=$1 [L]

So, all good there & works fine on the development site. The problem is we're now ready to switch to the live domain, and the client has a current site and so we are moving the hosting at the same time. on our server, the domain is setup and all the files there ready to go. the temporary URL that cPanel gives us looks something like this: http://00.00.000.000/~cli/_clientsite.com/.

The homepage of the site comes up just fine in the final testing as it doesn't rely on the url rewrite, but the interior pages are giving a 404 error, which i think is because of the rewrite rule not kicking in properly.

I only need this to work for the testing as we can't afford this to go live and not work. Is there a way around this?

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

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

发布评论

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

评论(1

孤蝉 2024-12-11 01:02:04

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

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