Php 本地主机的Codeigniter htaccess
我在codeigniter路由方面遇到了一些问题。我在托管服务器上有一个实时站点&下面是它的访问权限Php 本地主机的Codeigniter htaccess,php,.htaccess,codeigniter,routing,Php,.htaccess,Codeigniter,Routing,我在codeigniter路由方面遇到了一些问题。我在托管服务器上有一个实时站点&下面是它的访问权限 #php_value memory_limit 256M #php_value upload_max_filesize 50M #php_value post_max_size 70M AddType font/opentype .otf AddType application/vnd.ms-fontobject .eot AddType font/ttf .ttf AddType app
#php_value memory_limit 256M
#php_value upload_max_filesize 50M
#php_value post_max_size 70M
AddType font/opentype .otf
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType application/font-woff .woff
AddDefaultCharset utf-8
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
RewriteRule ^favicon.* - [L]
RewriteRule ^search /categories [R=301,L]
RewriteRule ^login / [R=301,L]
RewriteRule ^pages/disclaimer /pages/integritetspolicy [R=301,L]
RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^index.php$ http://%{HTTP_HOST} [R=301,L]
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (utredningar/post)
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(utredningar/post)
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
到
我更改了应用程序/config/config.php,添加了基本url,删除了index.php等等
4.我已经想尽一切办法让它发挥作用,请指出我哪里做错了。。非常感谢这是我的
.htaccess
,它既适用于生产也适用于开发服务器
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
config.php
$config['base_url'] = '';
$config['index_page'] = '';
# Default
$route['default_controller'] = "home";
routes.php
$config['base_url'] = '';
$config['index_page'] = '';
# Default
$route['default_controller'] = "home";
1.在
application/config.php
文件中进行以下更改
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
2.使用下面的代码在根目录中创建.htacces
文件
RewriteEngine on
RewriteBase /codeigniter // add this
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
我尝试了上面所有的解决方案,但没有一个对我有效,所以我到处转转,现在我的本地服务器工作得很好 以下是你需要做的:正如萨蒂所说
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
然后添加此htaccess代码:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
谢谢你的快速回复@Parag,但我以前试过。。它对我不起作用,您使用的是哪个版本的CI?它是2.1,但我也将系统更改为2.2。。仍然不起作用..你在使用godaddy服务器吗?不在godaddy中,另一个托管服务器中的live web站点,live one工作得很好,但我无法使其成为localhost..:(如果您说资产也没有加载,那么您的服务器肯定存在配置问题。您确定文件正在读取吗?如果您将
abcdefgh0123
放在文件的开头,是否会引发内部服务器错误?@UdayaSri对我的代码重写库/codeigniter进行少量修改检查此链接我尝试了@stay,但是仍然不起作用。我在以前的项目中使用了htaccess,它工作正常。但是对于这个,它不起作用。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]