大家好我试图隐藏url中的index.php,就像那样:
我想:mydomain.com/index.php/mycontroler
如:mydomain.com/mycontroler
这是我的.htaccess
Options -Multiviews
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]
这是我的conf.php
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
问题是它在本地运行良好但不在服务器
这是我的文件的配置
- bin
- etc
- mail
- public_ftp
- public_html
-- application
-- assets
-- system
-- .htaccess
-- index.php
帮助人
答案 0 :(得分:2)
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/';
$config['index_page'] = '';
htaccess的:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
如果仍然遇到麻烦尝试改变:
$config['uri_protocol'] = 'REQUEST_URI';
to
$config['uri_protocol'] = 'AUTO';
或somenthing不同更多(在config.php中你会找到所有可用于uri_protocol参数的选项)
答案 1 :(得分:0)
这是.htaccess的东西,
<IfModule mod_rewrite.c>
Options +FollowSymLinks -Indexes
RewriteEngine on
# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
#RewriteBase /
# Restrict your site to only one domain
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
</IfModule>
#prevent access to htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
#disable directory browsing
Options All -Indexes
IndexIgnore *
在config.php中
答案 2 :(得分:0)
我所有的.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|static)
RewriteRule ^(.*)$ /index.php/$1 [L]
并且您应该确保属性AllowOverride
设置正确,例如:AllowOverride ALL
目录段中的httpd.conf
答案 3 :(得分:0)
在根.htaccess文件中进行以下更改
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
它对我有用。