Mod_rewrite 头痛
好吧,我只是想为网站设置一个简单的重写规则。 首先,在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,只要您有一个
Alias
,您就需要一个RewriteBase
来使事情按预期工作。在您的情况下,您应该具有
与您的规则相同的 .htaccess 。
In general, whenever you've got an
Alias
, you're going to need aRewriteBase
to make things work as expected.In your case, you should have
in the same .htaccess as your rules.