简体   繁体   English

htaccess重写不在localhost上工作

[英]htaccess rewrites not working on localhost

While there are many similar posts, I have read them all to no avail. 虽然有很多类似的帖子,但我读过它们都无济于事。 Let me describe my situation in hopes that someone can resolve this issue. 让我描述我的情况,希望有人可以解决这个问题。 I have the following .htaccess file living in /Users/myusername/Sites/domain.com/public_html/.htaccess. 我有以下.htaccess文件,位于/Users/myusername/Sites/domain.com/public_html/.htaccess中。 The DocumentRoot is set to /Users/myusername/Sites/domain.com/public_html. DocumentRoot设置为/Users/myusername/Sites/domain.com/public_html。

RewriteEngine on
options +FollowSymLinks

RewriteBase /demo 
RewriteRule ^/demo/evaluate/1$ /demo/evaluate/index.php?eval_id=1 [L]

Now for the settings: 现在进行设置:

  1. "LoadModule rewrite_module modules/mod_rewrite.so" in httpd.conf is uncommented. httpd.conf中的“LoadModule rewrite_module modules / mod_rewrite.so”已取消注释。
  2. "AllowOverride All" everywhere 到处都是“AllowOverride All”

The htaccess redirects work, but for some reason I just keep getting the following error in my error logs: htaccess重定向工作,但由于某种原因,我只是在我的错误日志中得到以下错误:

[Sun Apr 22 11:14:09 2012] [error] [client ::1] File does not exist: /Users/myusername/Sites/domain.com/public_html/demo/evaluate/1

Please let me know if you need any more information. 如果您需要更多信息,请与我们联系。


Honestly, not sure what happened. 老实说,不确定发生了什么。 I did not change anything. 我什么都没改变。

It could have been some magic combination of all of the settings and feedback. 它可能是所有设置和反馈的神奇组合。 But now it is working. 但现在它正在发挥作用。 It's like a house of cards that I am just going to step back from and marvel at until I accidentally break it again. 它就像一个纸牌屋,我只是要退后一步,直到我意外地再次打破它。

尝试将您的RewriteRule更改为:

RewriteRule ^demo/evaluate/1$ demo/evaluate/index.php?eval_id=1 [NC,QSA,L]

Can you please check these two lines and check 你可以检查这两行并检查

RewriteBase /demo 
RewriteRule ^/demo/evaluate/$1 /demo/evaluate/index.php?eval_id=$1 [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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