简体   繁体   中英

CodeIgniter htaccess mod_rewrite not working properly

I'm trying to make the url into http://127.0.0.1/dev/blog/welcome but when I type that it changes the url to http://127.0.0.1/dev/blog/index.php/welcome

But When I do http://127.0.01/dev/blog//welcome it stays like that for some reason.

my .htaccess is

RewriteEngine On
RewriteBase /dev/blog
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]

and my config.php is configured

$config['base_url'] = 'http://127.0.0.1/dev/blog/';
$config['index_page'] = '';

Oh, and I did check if mod_rewrite is on and I'm using WAMP

Another info: I'm using Firefox but when I use IE(9) It doesn't change the url from http://127.0.0.1/dev/blog/welcome to http://127.0.0.1/dev/blog/index.php/welcome

For your RewriteRule , add the NC and QSA flags. The QSA ensures that query strings are appended. Unless you are planning on CodeIgniter manage your css files, images, and robots.txt, leave out the penultimate line too.

Try this:

RewriteEngine On
RewriteBase /dev/blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]

Also, check your uri_protocol in config.php. I've had some problems with WAMP not detecting it properly, and have had the most luck with setting it to PATH_INFO instead of AUTO .

您是否在apache配置中将AcceptPathInfo设置为ON

Make sure you are editing the file on your webroot dir and not on the application dir. I've struggled a little bit while trying to get this to work properly until I finally figured that was my problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM