Mod_rewrite 头痛

发布于 2024-12-09 08:59:48 字数 1060 浏览 1 评论 0原文

好吧,我只是想为网站设置一个简单的重写规则。 首先,在 httpd.conf 中我有

LoadModule rewrite_module modules/mod_rewrite.so

然后在一个单独的文件中我有这个别名设置

Alias /vworker/ "f:/vWorker/" 

<Directory "f:/vWorker/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order allow,deny
    Allow from all
</Directory>

现在好了,所以网站的目录

f:/vWorker/urlmask

在那里 我有一个 .htaccess 文件,上面写着

RewriteEngine on
RewriteRule ^redirect/([0-9]+)/?$ index.php?redirect=$1 [L]

现在,我想要的是,如果我去到 URL http://localhost/vworker/urlmask/redirect/3161513 它实际上会调用 http://localhost/vworker/urlmask/index.php?redirect?3161513

从我的角度来看,一切似乎都设置正确,如果我在我的 .htaccess 文件中放入乱码我收到服务器错误,所以我知道它正在读取它。

我最终得到的页面显示“未找到。在此服务器上找不到请求的 URL /vworker/urlmask/redirect/94173336828903446”。 有什么想法我做错了吗?

Alright, I'm just trying to setup a simple rewrite rule for a site.
First off, in httpd.conf I have

LoadModule rewrite_module modules/mod_rewrite.so

Then in a seperate file I have this alias setup

Alias /vworker/ "f:/vWorker/" 

<Directory "f:/vWorker/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order allow,deny
    Allow from all
</Directory>

Alright now, so the directory of the site is

f:/vWorker/urlmask

In there I have an .htaccess file that says this

RewriteEngine on
RewriteRule ^redirect/([0-9]+)/?$ index.php?redirect=$1 [L]

Now, what I want, is if I go to the url http://localhost/vworker/urlmask/redirect/3161513 it will actually call http://localhost/vworker/urlmask/index.php?redirect?3161513

From my point of view everything seems to be set up right, and if I put gibberish in my .htaccess file I get a server error, so I know it's reading it.

What I end up with is a page that says "Not Found. The requested URL /vworker/urlmask/redirect/94173336828903446 was not found on this server."
Any ideas what I'm doing wrong?

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

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

发布评论

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

评论(1

苦笑流年记忆 2024-12-16 08:59:48

一般来说,只要您有一个 Alias,您就需要一个 RewriteBase 来使事情按预期工作。

在您的情况下,您应该具有

RewriteBase /vworker/urlmask/

与您的规则相同的 .htaccess 。

In general, whenever you've got an Alias, you're going to need a RewriteBase to make things work as expected.

In your case, you should have

RewriteBase /vworker/urlmask/

in the same .htaccess as your rules.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文