How to keep URL display unchanged after redirecting root folder to sub folder
I want to redirect all queries to mydomain.com to mydomain.com/live/. I'm already able to do that, however I have trouble with the URL displayed in the browser. I have two goals, (1) that the URL always renders with "www" in front and (2) that the sub folder "live" is not displayed in the url.
EDIT: Based on edited code by Cryo the following accomplishes my goals and also adds a trailing slash after all subfolders so that when a 开发者_开发百科folder is typed in the url it's correctly forwarded to the index.html inside of it:
RewriteCond %{HTTP_HOST} !^www\.domain\.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteRule ^$ /index.html
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.domain.com/$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/live/
RewriteRule ^(.*)$ /live/$1
Question though, when adding a trailing slash to subfolders, I assumed RewriteCond %{REQUEST_FILENAME} !-f would make it so that a slash isn't added after file names (only folders) so /subfolder/page.html would not have a trailing slash (which is what I want). However RewriteCond %{REQUEST_FILENAME} !-f seems to do nothing and RewriteCond %{REQUEST_URI} !..+$ is needed.
RewriteCond %{HTTP_HOST} !^www\.georgemitra\.com$
RewriteRule ^(.*)$ http://www.georgemitra.com/$1 [R=301,L]
RewriteRule ^$ /index.html
RewriteRule ^blog$ /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/live/
RewriteRule ^(.*)$ /live/$1
You almost had it. I moved the www subdomain catch-all to go first and push it to the browser before continuing. Then when the request comes back I just added the index.html force on the root and the catch for /blog without a trailing slash. Hope that helps.
If you want to avoid putting 'live' in the URL it sounds like what you want is not a redirect but a reverse proxy.
精彩评论