Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
783 views
in Technique[技术] by (71.8m points)

.htaccess - Remove index.php from codeigniter in xamp

I've tried quite a few answers but keep coming up against the good ol, 404 wall of terror. I'm on Windows 7 using a xamp stack. mod_rewrite is enabled.

I put the htaccess file in the main "codeigniter" directory, that is, the directory with application, system and user_guide. Should I put it under the application directory instead? The one with the views/model/config/etc.?

Here is my current .htaccess file:

RewriteEngine On

# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/

RewriteBase /website/codeigniter/

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule .* index.php/$0 [PT] 

Accessing http://localhost/website/codeigniter/index.php/welcome works Accessing http://localhost/website/codeigniter/welcome does not

My config.php has

$config['base_url'] = 'http://localhost/website/codeigniter/';
$config['index_page'] = '';

Any help greatly appreciated!

The error is:

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

Error 404

UPDATE Oh, just thought about looking in apache logs, getting this error:

[Thu Mar 08 18:28:25 2012] [error] [client ::1] File does not exist: C:/xampp/htdocs/website/codeigniter/welcome

So it appears not to be picking up the proper codeigniter redirection? Not sure?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

first create .htacess file and paste below code in that RewriteEngine on

RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

then go to config file

$config['index_page'] = 'index.php';

change to

$config['index_page'] = '';

and enjoy


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...