[英]Codeigniter remove index.php - htaccess localhost
我已经尝试了我在堆栈溢出时找到的所有解决方案但没有成功。
我在跑
随着最新版本的Smarty 3.所有这一切正常,直到我尝试从URL中删除'index.php'。
config.php文件
$config['base_url'] = 'localhost';
$config['index_page'] = '';
routes.php文件
$route['default_controller'] = 'home';
$route['contact'] = 'contact';
的.htaccess
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /responsive_template/
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
启用了Apache的“LoadModule rewrite_module modules / mod_rewrite.so”
<Directory />
AllowOverride all
Require all denied
</Directory>
如果我访问localhost/responsive_template/index.php/contact
一切正常,只有localhost/responsive_template/contact
以404结尾,就是这样。
整个codeigniter应用程序文件夹位于c:\\xampp\\htdocs
下的子目录'responsive_template'中
感谢任何帮助,非常感谢。
BR大卫
我发现xampp和wamp这个htaccess使用完整。
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
使您将htaccess文件放在主应用程序文件夹的一侧 。
设置你的基本网址有点像
$config['base_url'] = 'http://localhost/project/';
$config['index_page'] = '';
注意:您可以将基本网址留空,但有时您提交的表单可能无法正确提交。 因为它在url而不是
localhost
显示ip_adress
目录
application
system
.htaccess
index.php
使用codeIgniter 3版本时,请确保您的类和文件名首字母大写。
文件名示例: Welcome.php
<?php
class Welcome extends CI_Controller {
public function index() {
}
}
你应该试试这个:
------------------------------------ config.php ----------------------------
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';// if this will not work. comment this line and remove comment from below line
// $config['uri_protocol'] = 'AUTO';
---------------------------------- .htaccess -----------------------------
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
注意: - 确保您的.htaccess文件位于根目录。 在带有index.php文件的responsive_template目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.