.htaccess在xampp上不起作用(Windows 7)

I'm setting my .htaccess file right now to use friendly urls (manually). But, when i go to the url the server shows me Error 404.

RewriteEngine on

RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  

Rewriterule ^register$ register.php 

I'm really sure that mod_rewrite is enabled because i see it when use phpinfo().

Even though mod-rewrite is enabled, by default it is not enabled for .htaccess files.

Hold Your Breath

  • Open xampp control panel
  • Stop Apache
  • Click the Config button on the Apache row, and select httpd.conf
  • In that file, search for something like xampp/htdocs">
  • A bit lower, you may see a line like this: # AllowOverride All. Remove the #, which is a comment
  • Alternately, search for AllowOverride All, make sure it is in the right section, and remove the comment #
  • Save the file
  • Restart Apache, say a prayer, cross your fingers and hold your breath

Check in httpd.conf you tag, review this property

AllowOverride All

AllowOverride authorize use htaccess file.

This listing may be old but is still relevant so to make it a little more secure it is probably best to add a few lines.

Deny from all
Allow from 127.0.0.1 ::1 localhost
Allow from .htaccess

Also as a side note .htaccess files slow the speed of the server so it would be best to refer to xampp documentation for best practices.

Hope it helps.

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

if we want to remove index.php form url .First we create a .htaccess file on root directory of project with out any extension. And add this code in this file and so remove the index.php Application/config/config.php