.htaccess 重写不起作用

发布于 2024-09-06 04:43:33 字数 406 浏览 1 评论 0原文

我需要重写 .htaccess 方面的帮助。

我正在尝试执行以下操作: 当用户输入 http://www.example.com/csc/alabama/ 我需要从 http://www.example.com/csc/index.php?state=alabama 提取信息

我认为应该是这样,

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^csc/([^/]*)$ /csc/index.php?state=$1 [L]

我不断收到 404 错误。

顺便说一句,我希望能够使用通用子目录来完成此操作,以便 csc 可以是 abc 或其他任何内容,但这不是优先事项。

I need help with a rewrite in .htaccess.

I am trying to do the following:
When a user types http://www.example.com/csc/alabama/
I need to pull info from http://www.example.com/csc/index.php?state=alabama

I thought it should be this

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^csc/([^/]*)$ /csc/index.php?state=$1 [L]

I keep getting a 404 error.

On a side note, I would like to be able to do this with a generic sub-directory, so that csc could be abc or anything else but this is not the priority.

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

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

发布评论

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

评论(1

时光无声 2024-09-13 04:43:34

您忘记了模式中的尾部斜杠。您还应该排除要重定向到的目的地:

RewriteCond $1 !=index.php
RewriteRule ^csc/([^/]*)/$ /csc/index.php?state=$1 [L]

You forgot the trailing slash in your pattern. You should also exclude the destination you are redirecting to:

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