开发者

mod_rewrite error: [client 127.0.0.1] File does not exist

I want to start using mod_rewrite so i can use friendly url's in the future. Im testing all in my localhost dev. environment but, Im not having any luck getting the module to work!

My modules is enabled (apache restarted):

LoadModule rewrite_module modules/mod_rewrite.so

The file named mod_rewrite.so exists u开发者_StackOverflow中文版nder the modules folder in my Apache installation directory

I've created a file named .htaccess under c:/public_html/

For testing purposes, ive created my first rules like so:

RewriteEngine On
# Translate my-product.html to /product.php?id=123
RewriteRule ^my-product\.html$ /product.php?id=123

for testing purposes, the product.php is extremely simple:

<?php
  // display product details
  echo 'You have selected product #' . $_GET['id'];
?>

When i load http://localhost/my-product.html I get the error:

The requested URL /my-product.html was not found on this server.

When i go see the log, i see:

[Thu Sep 22 02:37:49 2011] [error] [client 127.0.0.1] File does not exist: C:/public_html/my-product.html

It looks like it doesn't recognize the .htaccess rule at all!

I'm not sure what to do next, i feel i've applied all the simpliest rules to get started with mod_rewrite but with no luck!

Help!

Thanks Marco


Have you changed the Allowoverride property in httpd.conf file to 'All'.

To check whether the mod-rewrite is enabled in your server, load the phpinfo file and search for the mod_rewrite extension.


You should configure the mod_rewrite logging, so you can see what happens. Look up the RewriteLog directive in the manual.

Initially you can set the log level to 9 (for learning). As long as the file stays empty, the .htaccess is ignored, as you already suspected.

You can also just write rubbish into the .htaccess to see if it gets interpreted at all. If it does, you will get a 500 Internal Server Error. If not, you must configure the directory C:/public_html to allow htaccess files. See the Options directive in the manual.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜