Drupal Clean URL 随机中断任意路径
我一切都做对了。我的服务器已启用 mod_rewrite,我的虚拟主机路径已将 AllowOverride 设置为“全部”,并且我已准备好 .htaccess 文件,其重写规则与其他人相同。但我无法使用干净的 url 路径访问某些页面。因此,对于 90% 的页面,干净的 url 效果很好。但对于那 10%,他们却没有。
我检查过这些页面是否存在——它们确实存在。检查它们是否可以使用index.php?q=[path] 访问——确实如此。它们只能通过干净的 url 路径访问。
谁能帮我解开这个谜团吗?
I've done everything right. My server has mod_rewrite enabled, my virtualhost path has AllowOverride set to All, and I have the .htaccess file in place with the rewrite rules same as everyone. But I have trouble accessing some pages using their clean url paths. So for 90% of the pages, clean urls work fine. But for that 10%, they don't.
I have checked whether those pages exist -- they do. Checked whether they are accessible using index.php?q=[path] -- and they are. They are only inaccessible through clean url paths.
Can anyone help me with this mystery?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为您可以通过 q=path/to/menu/item 访问您的页面,所以很明显是 mod_rewrite 有问题,而不是 Drupal。
要调试重写的情况,请打开 重写日志 并在请求有问题的页面时使用 tail -f it,或者在 index.php 或 page.tpl.php 顶部的 print_r($_GET) 来查看实际请求的内容。
如果您愿意在此处发布可能敏感的 .htaccess,请这样做,我们可以帮您查看它是否存在任何配置错误。
Because you can access your pages through q=path/to/menu/item, then it's clear that it is mod_rewrite that is at fault and not Drupal.
To debug what is going on with your rewrite, either turn on the rewrite log and tail -f it while you request the troubled pages, or alternatively print_r($_GET) at the top of index.php or page.tpl.php to see what is actually being requested.
If you are comfortable posting your potentially sensitive .htaccess here, do so and we can have a look at it for you to see if there are any misconfigurations.
mod_rewrite
有一些长期存在的错误,这些错误会在传输过程中破坏 URL(您的问题 URL 是否有任何转义字符?)。我不知道 Drupal 是否这样做,但在其他 PHP 应用程序中,一旦到达正确的入口点,我就必须添加代码来重新进行重写。不幸的是,Drupal 无法在
PATH_INFO
中获取其搜索路径(就像许多其他应用程序一样),否则您可以使用mod_alias
,它更简单、更可靠。mod_rewrite
has a few long-standing bugs that mangle URLs on the way through (do your problem urls have any escape characters?). I don't know if Drupal does this, but in other PHP apps I have had to add code to re-do the rewrite once the correct entrypoint has been reached.Unfortunately, Drupal can't take its search path in
PATH_INFO
(as a lot of other apps do), otherwise you could usemod_alias
which is much simpler and much more reliable.