htaccess 重定向到文件夹
我不确定标题应该是什么,但它的概念很简单,但我对 .htaccess 重写毫无用处。
我目前有:
RewriteRule ^([a-zA-z0-9_-]+)/?$ index.php?page=$1
它将很乐意将所有请求发送到我的索引,我可以做我想做的事。
我有:
RewriteRule ^events/([a-zA-Z0-9-./]+)/?$ index.php?page=events/index&id=$1
对于更多间歇性的东西..
但我想说
如果网址是“/mycms/...”将使用发送到%{HTTP_HOST}/cms并留在那里...
任何人都可以帮助?我的“包罗万象”规则总是把事情搞砸。
编辑我让它工作得很好
RewriteRule ^mycms([a-zA-Z0-9-./]+)?$ /cms$1 [L]
RewriteCond %{REQUEST_URI} !^/cms
RewriteRule ^([a-zA-z0-9_-]+)/?$ index.php?page=$1
现在我写http:// /localhost/mycms 并将前往 http://localhost/cms
我仍然想屏蔽 '/cms/' 文件夹... o_O
I wasn't sure what the title should be but its s simple concept but I'm useless with .htaccess rewrites.
I currently have:
RewriteRule ^([a-zA-z0-9_-]+)/?$ index.php?page=$1
which will happily send all requests to my index and I can do what I want.
I have:
RewriteRule ^events/([a-zA-Z0-9-./]+)/?$ index.php?page=events/index&id=$1
For more intermit stuff..
But I want to say
If the url is "/mycms/..." Send use to %{HTTP_HOST}/cms and stay there...
Can anyone help? my 'catch all' rule keeps fecking it up.
Edit I Got this to work wonderful
RewriteRule ^mycms([a-zA-Z0-9-./]+)?$ /cms$1 [L]
RewriteCond %{REQUEST_URI} !^/cms
RewriteRule ^([a-zA-z0-9_-]+)/?$ index.php?page=$1
Now I write http://localhost/mycms and will head off to http://localhost/cms
I still want to mask the '/cms/' folder though... o_O
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需要在 catch all 之前进行重写,并使用 L 标志来防止它再次被重写,这样的事情就足够了。
You just need to place a rewrite before your catch all and use the L flag to prevent it being rewritten again, something like this should suffice.