[英]Codeigniter can't remove index from url
我正在使用CentOS,
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|resources)
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteBase /var/www/html/site/
</IfModule>
但同样的问题我的index.php页面工作正常,但当我删除index.php它不工作...
我认为它会帮助你,因为我正在使用这个。将此代码放在根文件夹的htaccess文件中。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
如果它正常工作,请告诉我。
这可能是一些事情。
1(从配置文件中删除索引页面(application / config / config.php)
$config['index_page'] = '';
2(你有这样的base_url:
$config['base_url'] = 'http://yourdomain.com/';
注意/
最后。
3(试试这个.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^LoginTut.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond $1 !^(index\.php|images|table-images|js|robots\.txt|css|captcha)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
简单地在config
文件夹的config.php
文件中搜索索引url(index_page)并将其设置为空
$config['index_page'] = '';
试试这个对我有用ccnd是我的文件夹。
RewriteEngine on
RewriteCond $1 !^(index\.php|uploads|images|css|js|lib|img|bootstrap|robots\.txt)
RewriteRule ^(.*)$ /ccnd/index.php/$1 [L]
RewriteEngine On
RewriteBase /site_root/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
重要事项:1。你必须设置$config['index_page'] = '';
在config.php文件中。 2. site_root是文件夹名称,如wamp / www / site_root。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.