.htaccess重写规则,如果是特定文件夹
我需要对.htaccess文件进行一些帮助,专门使用重写规则
我的目录结构:
root
├── plans
│ │── .htaccess
│ │── app
│ └── public
└── Wordpress
结果我想要的结果:
如果用户转到目录https:// localhost:8888/plans/plans/ HTACCESS文件将其重写为子文件夹 public (https:// localhost:8888/plans/public),
我到目前为止尝试过的是,
RewriteEngine On
RewriteRule ^$ /public/ [L]
这给了我的404错误。
这是可能的,我该怎么做?
I need some help with my .htaccess file specifically with a rewrite rule
My directory structure:
root
├── plans
│ │── .htaccess
│ │── app
│ └── public
└── Wordpress
The result what I want:
If the user goes to the directory https://localhost:8888/plans/
The htaccess file rewrite this to the subfolder public (https://localhost:8888/plans/public)
What I tried so far
RewriteEngine On
RewriteRule ^$ /public/ [L]
This gives my a 404 error not found.
Is this possible and how can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在
plan/.htaccess
中使用此规则:这将在
/plans/
中将所有路径重写为/plans/plubly/public/
。(?!public/)
如果URI已经是/plans/public/public/
,可以停止重写的负面lookahead。You may use this rule in
plans/.htaccess
:This will rewrite all paths in
/plans/
to/plans/public/
.(?!public/)
is a negative lookahead to stop rewrite if URI is already/plans/public/
.