htaccess的重定向文件夹 [英] .htaccess redirect folder

查看:163
本文介绍了htaccess的重定向文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有,

我想重定向来 HTTP的所有流量:// mysite的/ 到的 HTTP:// mysite的/公共的文件夹中。目前我使用下面的.htaccess文件这样做的,它的工作原理为根目录。但是,如果我浏览到的http:// mysite的/应用,它不重定向,并显示目录列表。我希望所有的流量,无论它是什么文件夹重定向到的http:// mysite的/公共文件夹

I want to redirect all traffic that comes to http://mysite/ to http://mysite/public folder. Currently I am doing this using the below in an .htaccess file and it works for the root directory. But if I browse to http://mysite/application, it doesn't redirect and shows the directory listing. I want all traffic regardless of what folder it is to redirect to http://mysite/public folder

RedirectMatch permanent ^/*$ /public/

感谢

推荐答案

试试这个 mod_rewrite的例如:

RewriteEngine on
RewriteRule !^public/ /public%{REQUEST_URI} [L,R=301]

这篇关于htaccess的重定向文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆