apache - 我应该如何成功重写 url 以在远程服务器上使用?
问题描述
我的网站在本地主机上正常工作,但在上传到远程服务器时,只有 index.php 页面在工作。其他 URL,如登录(见下文)不起作用并返回 404 Not Found 错误。
模型-视图-控制器设计模式已经实现,因此站点上的所有页面都使用适当的视图文件通过 index.php 呈现。
简单地说,该网站的设计工作如下:
index.php 页面存储在:www.subdom.mysite.com/public
通过链接 www.subdom.mysite.com/public/user/login 登录站点,其中“user”是控制器 PHP 类文件,“login”是该类的方法。'user' 和 'login' 用于重写 url。'login' 方法准备用户登录表单所需的 html 并将其传递给 'index' 视图以在浏览器中呈现。
其他网站功能的工作原理与上述相同,例如,通过 www.subdom.mysite.com/public/bank/payment 进行银行付款
下面是我的 .htaccess 文件 - 也存储在上面的 /public 文件夹中。上传到远程服务器后,我对该文件所做的唯一更改是在 RewriteBase 行上。
Options -MultiViews
RewriteEngine On
######################
# Localhost version of the RewriteBase statement:
# RewriteBase /subdom/public
######################
# Remote server version of the RewriteBase statement (as displayed in host's cPanel):
RewriteBase /home2/user/subdom.mysite.com/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?atid=$1 [QSA,L]
在过去的几天里,我一直在为这个问题而烦恼。我不知道我遗漏了什么或需要进行哪些修改,因此非常感谢您的帮助以使其正常工作。
解决方案
推荐阅读
- android - Flutter:无法在调试或发布中构建 android
- android - 如何在 TextView 中禁用自动换行?
- django - 鹡鸰 i18n 混乱
- python - 登录名和密码变量
- sql - 值数组 ILIKE 某个值
- java - 在 java 中使用 API 创建 GitHub 分支
- python-3.x - 如何通过 AWS CDK 将基于资源的策略添加到使用 AWS SAM 创建的 Lambda 函数?
- python - 每当在 VSCode/Python 中遇到断点时运行代码
- python - 从两个不同的数据框中查找唯一的列值
- javascript - 根据有多少改变视频元素的大小