I have uploaded in production my website files in PHP made on the framework CodeIgniter. Though I changed the .htaccess files and its dependencies (config, etc.), still I have an error 404 as if the server could not access the controller file. This is my first try to put a site in production, any idea ?
我已经在生产中上传了我在PHP框架CodeIgniter上制作的网站文件。虽然我更改了.htaccess文件及其依赖项(配置等),但我仍然有错误404,好像服务器无法访问控制器文件。这是我第一次尝试将网站投入生产,任何想法?
.htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [L,R=301]
# Enforce NO www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]
###
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
config.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config['base_url'] = 'http://mywebsite.com';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'REQUEST_URI';
$config['url_suffix'] = '';
1 个解决方案
#1
Did you configure your base_url() function? It's in config.php file. If it's empty, it assumes taht you are working with localhost, so you have to put your domain there.
你配置了base_url()函数吗?它在config.php文件中。如果它是空的,它假设你正在使用localhost,所以你必须把你的域放在那里。
Go to config.php and find this line:
转到config.php并找到以下行:
$config['base_url'] = '';
and put your domain there.
并将您的域名放在那里。
$config['base_url'] = 'http://YOURDOMAINHERE.com';
#1
Did you configure your base_url() function? It's in config.php file. If it's empty, it assumes taht you are working with localhost, so you have to put your domain there.
你配置了base_url()函数吗?它在config.php文件中。如果它是空的,它假设你正在使用localhost,所以你必须把你的域放在那里。
Go to config.php and find this line:
转到config.php并找到以下行:
$config['base_url'] = '';
and put your domain there.
并将您的域名放在那里。
$config['base_url'] = 'http://YOURDOMAINHERE.com';