.htaccess 重写导致 404 错误

发布于 2025-01-08 14:34:27 字数 396 浏览 1 评论 0原文

我正在尝试使用以下 .htaccess 创建搜索引擎友好的 URL,无论我尝试什么,它都会定向到 404 错误页面。

如果有什么不同的话,这是在 Host Gator 共享帐户上。该目录是(文档根)/blog,.htaccess 文件位于目录“blog”中。

示例 URL 为 http://examplesite.com/blog/category/announcements。这是 .htaccess 文件内容:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^category/([a-zA-Z0-9]+)/$ index.php?category=$1

您知道为什么会发生这种情况吗?

I am trying to create search engine friendly URLs with the following .htaccess and it is directing to a 404 error page no matter what I try.

This is on a Host Gator shared account, if it makes any difference. The directory is (document root)/blog, the .htaccess file is located in the directory "blog."

Example URL would be http://examplesite.com/blog/category/announcements.Here is the .htaccess file contents:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^category/([a-zA-Z0-9]+)/$ index.php?category=$1

Any ideas why this is happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦开始←不甜 2025-01-15 14:34:27
RewriteRule ^category/([a-zA-Z0-9]+)/*$ index.php?category=$1 [R=301,L]
RewriteRule ^category/([a-zA-Z0-9]+)/*$ index.php?category=$1 [R=301,L]
心头的小情儿 2025-01-15 14:34:27

忘记前面的斜杠了吗?

RewriteRule ^category/([a-zA-Z0-9]+)/$ /index.php?category=$1

Forget the preceeding slash?

RewriteRule ^category/([a-zA-Z0-9]+)/$ /index.php?category=$1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文