mod_rewrite error: [client 127.0.0.1] File does not exist

≡放荡痞女 提交于 2019-12-12 01:57:37

问题


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 under 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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/7510829/mod-rewrite-error-client-127-0-0-1-file-does-not-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!