使用 htaccess 与 cPanel 临时 url 进行 url 重写
我们准备推出一个新网站。所有开发都是在一个单独的子域(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 RewriteCond 行之前,添加 RewriteBase 行,如下所示:
Before your RewriteCond lines, add a RewriteBase line like so: