大家好我尝试隐藏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
帮助家伙
$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 PARAM的选项)
这里的.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
- 设置基本URL像“ http://www.example.com/ ”
- $配置[“index_page”]设置为空
- 串设置$配置[ 'uri_protocol'] = 'REQUEST_URI'
我所有的.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|static)
RewriteRule ^(.*)$ /index.php/$1 [L]
你应该确保该属性AllowOverride
设置正确,如: AllowOverride ALL
在你httpd.conf
目录段
使根.htaccess文件下面的变化
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
它为我工作。