【问题标题】:SEF Joomla not working if page not exist (404)如果页面不存在,SEF Joomla 不工作 (404)
【发布时间】:2015-11-09 21:47:31
【问题描述】:

我有一台装有 Centos 6.5、Joomla 和 Nginx 的服务器。一切正常,我在 joomla 中启用了 SEF 以使用友好的 URL,例如:

example.com/the-­news/1­-latest-­news/1-­welcome-­to­-joomla.

在 nginx vhost example.conf 中,我输入了一行:

   location / {
      try_files $uri $uri/ /index.php?$args;
   }

这很好用,但是如果我输入一些不存在的 URL,比如example.com/asdasdasd,所以我被重定向到主页,索引(example.com),但我要显示 joomla 默认 404 错误页面,而不是重定向到索引页面。

有人知道怎么做吗?

谢谢大家!

【问题讨论】:

  • 所以你是说你应该得到一个 404 但你却重定向到主页? (这与人们通常问的相反。)
  • 是的,Elin,我想显示模板 404 错误,而不是重定向到主页。如果禁用 SEF,这可行,但 SEF 重定向到主页,我不知道为什么以及如何:/

标签: php nginx joomla


【解决方案1】:

您可以通过 .htaccess 文件强制加载您的 404 页面:

ErrorDocument 404 http://yourdomain.com/404.php

把它放在你的 .htaccess 文件的顶部

编辑:将 http://yourdomain.com/404.php 替换为您的 joomla 404 URL。

【讨论】:

  • 在 joomla + nginx 中我可以使用 .htaccess 吗?
  • 你可以转换它。使用这条指令:#nginx configuration error_page 404 http://yourdomain.com/404.php;
  • 你不能用 nginx 进行 .htaccess。这是错误的。
  • 我没有具体说它可以和nginx一起使用,并提供了nginx的配置说明。您可以将任何 htaccess 转换为 nginx 指令:winginx.com/en/htaccess
  • 我认为你的问题是 joomla,而不是 nginx。您需要将 args 传递给 index.php,并且您做得很好,但 joomla 不会重定向到 404 页面。我使用过 joomla 和 nginx,但我从未配置过 nginx 来返回 404,joomla 可以。如果您收到 404 或 301 代码,您能检查一下curl -I http://example.com/asdasdasd 吗??
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-01-31
  • 2014-01-21
  • 1970-01-01
  • 1970-01-01
  • 2018-08-26
  • 1970-01-01
  • 2011-04-24
相关资源
最近更新 更多