Jake
Jake

Reputation: 26107

.htaccess redirect folder

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

Upvotes: 2

Views: 2088

Answers (2)

Sonny
Sonny

Reputation: 8326

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.

Upvotes: 0

Gumbo
Gumbo

Reputation: 655169

Try this mod_rewrite example:

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

Upvotes: 4

Related Questions