Apache:mod_rewrite 不指向一个地址
所以我正在编写一个基于网络的程序,而不是在 URL 中包含大量 /?p=54&z=42
等,我将其设置为直接第一个“目录”(例如 /home/
)作为函数,第二个“目录”(例如 /home/view/
)作为操作。
现在,将其设置为 localhost/home/ 可以,将其设置为 localhost/settings/ 也可以,但是当我将其更改为 localhost/stats/< /code> 它尝试查找文件或文件夹...而不是将其重定向到要在 PHP 中使用的变量... 我之前确实有一个 .PHP 文件放在那里,但两天前将其删除。 Apache 仍在尝试查找那里的文件。我已经重新启动计算机十几次了,但没有成功。
我的 .htaccess 文件如下所示:
RewriteRule ^([a-z]+)/([0-9,a-z]+)$ /$1/$2/ [R]
RewriteRule ^([a-z]+)/([0-9,a-z]+)/$ /index.php?function=$1&action=$2 [L]
RewriteRule ^([a-z]+)$ /$1/ [R]
RewriteRule ^([a-z]+)/$ /index.php?function=$1 [L]
我做错了什么,我需要做什么才能使其正常工作?
So I'm writing a web based program, and instead of having a mass of /?p=54&z=42
, etc in the URL, I've set it up to direct the first "directory" (eg /home/
) to be the function, the second "directory" (eg /home/view/
) to be the action.
Right now, setting it as localhost/home/
works, setting it to localhost/settings/
also works, but when I change it to localhost/stats/
it tries looking for the file or folder... not redirecting it to a variable to be used in PHP...
I did have a .PHP file sitting there before but removed it 2 days ago. Apache is still trying to find the file that was there. I've restarted my computer a dozen times with no luck.
My .htaccess file looks like this:
RewriteRule ^([a-z]+)/([0-9,a-z]+)$ /$1/$2/ [R]
RewriteRule ^([a-z]+)/([0-9,a-z]+)/$ /index.php?function=$1&action=$2 [L]
RewriteRule ^([a-z]+)$ /$1/ [R]
RewriteRule ^([a-z]+)/$ /index.php?function=$1 [L]
What am I doing wrong, and what do I need to do to get this working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的 httpd.conf 或虚拟主机的 conf 文件中,您可能有一个别名或类似的东西,使其在达到规则之前处理 /stats/ 。
In your httpd.conf or virtual host's conf file, you probably have an alias or something like that that makes it process /stats/ before the rules are reached.
原来根目录中有一个名为
stats.deadphp
的文件导致了问题。删除就清除了。 :)Turns out there was a file called
stats.deadphp
in the root directory that was causing the issue. Deleting that cleared it up. :)