开发者

.htaccess redirect folder

开发者 https://www.devze.com 2022-12-18 19:56 出处:网络
All, 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. Bu

All,

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/

Thanks


Try this mod_rewrite example:

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


I see that you're using Zend Framework. Zend uses 'public' as the exposed web folder, but you should use the folder dictated by your web host. What is the name of the server-side folder that is exposed to the web? Your file structure should be like this:

application/
[web_exposed_dir]/
library/

In my case, the [web_exposed_dir] is called 'content'. You won't have to redirect everything to 'public' if you do it the way I've outlined.

0

精彩评论

暂无评论...
验证码 换一张
取 消