【发布时间】:2016-10-06 14:36:08
【问题描述】:
我正在使用 Capistrano 部署我的 CI3 站点,但对重写规则知之甚少。我能够从 stackoverflow 中找到 htaccess 规则,但它们都不适用于我的情况,所以我在这里。
我设法让我的主页在没有任何程序的情况下运行,但没有一条路线适合我。它们都返回 CI3 404 page not found 错误。
我的网站结构:
|-- .htaccess (under domain root)
|-- app/
|-- current/ -> symlink to latest release folder
|-- application/
|-- public/
|-- index.php
|-- .htaccess (under project root)
|-- ...other CI 3 folders and files
|-- shared/
|-- repo/
|-- shared/
|-- releases/
.htaccess(域根目录下)
RewriteEngine On
RewriteBase /
# remove www
RewriteCond %{HTTP_HOST} !^siteurl.com$
RewriteRule ^(.*)$ http://siteurl.com/$1 [L,R=301]
# redirect to CI3 root
RewriteCond %{REQUEST_URI} !^/app/current/
RewriteRule ^(.*)$ /app/current/$1 [L]
.htaccess(在项目根目录下)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
config.php
$config['base_url'] = 'http://siteurl.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
routes.php
$route['default_controller'] = 'welcome';
$route['api/oauth'] = 'api/oauth';
到目前为止,欢迎页面运行良好,但路由 api/oauth 的 CI3 404 错误页面返回。
请帮忙!!!非常感谢!!!
【问题讨论】:
标签: .htaccess codeigniter capistrano codeigniter-3 capistrano3