我试过在Ubuntu服务器上托管一个CodeIgniter网站。.htaccess无法正常工作 - CodeIgniter
所有其他网站工作正常,没有任何问题(服务器包含WordPress和Laravel应用程序)。但是这个特殊的CodeIngniter网站并没有采用.htaccess文件。我花了一天的时间来解决这个问题,但没有运气。
这是细节。
网站URL结构:http://example.com/website_name
.htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
虚拟主机条目
<VirtualHost *:80>
ServerName example.com
ServerAlias example.com
DocumentRoot "/var/www/example.com"
<Directory "/var/wwww/example.com">
Options Indexes FollowSymLinks MultiViews
AllowOverride ALL
Order allow,deny
allow from all
</Directory>
</VirtualHost>
笨配置文件
$config['base_url'] = 'http://example.com/website_name/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
,当我试图访问该网站的输出如下,
Not Found
The requested URL /website_name/test was not found on this server.
但是如果我添加的index.php,在该网站的工作没有任何问题。我尝试了很多方法,但没有奏效。
试过这个,没有工作。 – Nikhil
RewriteBase/website_name/ – AldoZumaran
将htaccess文件放到website_name文件夹中 – AldoZumaran