Internal redirection: Serve “/site” as “/” and “/sub/blog” as “/blog”
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, shared-hosting, , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :I have a website with a shared hoster. There are a few things that I have there, like main site, Piwik, a blog and other standalone things.
Right now I have the following structure:
~/subs/wwwgets served asexample.organdwww.example.org~/subs/bloggets served asblog.example.org~/subs/app/piwikgets served asapp.example.org/piwik~/subs/app/foogets served asapp.example.org/foo
This is a all nice, I have separate cookies for the different applications. However, I would need a wildcard TLS certificate in order to get everything encrypted. Especially since Piwik is included in the main page, it must also be served over a secure connection. The provider wants 10 EUR/month for the wildcard certificate.
Now they offer one free certificate which I have issued for example.org and getting www.example.org for free. In consequence I would have to serve everything from example.org in order to get consistent TLS.
From a user standpoint, I would like to have the following URLs:
/is the main site/blogis the blog/app/piwikpoints to the Piwik installation/app/foopoints to some other stand-alone application
I do like the directory structure on the server, especially since I can just rsync --delete into the ~/subs/www directory and automatically prune files that I have deleted on disk. If I would upload the files such that they get served correctly, I would not do this any more.
So I would like to do this:
~/subs/wwwis served atexample.org/~/subs/blogis served atexample.org/blog~/subs/app/piwikis served atexample.org/app/piwik
From this question I gathered that the following .htaccess should do the trick:
RewriteEngine On
RewriteBase /
RewriteCond %REQUEST_URI !^/subs/
RewriteRule ^blog(.*) /subs/blog$1 [L]
However, when I request example.com/blog in my browser, I get redirected to example.com/subs/blog. I don't want to redirect, I want to do this mapping in the background such that the visitor will never see the URL fragment /subs/.
The shared hoster is Domain Factory, I can put in .htaccess files but I cannot alter any configuration files that need root access to the system.
How can achieve this?
From what i gather, try this :
RewriteRule ^blog$ /subs/blog [L]
and save it in your roots (www) folder's .htaccess
But i believe that your best bet would be to do a direct redirection such as
Options +FollowSymLinks
Redirect ~/subs/blog/ http://www.yourdomain.com/blog/$1
Comments
Post a Comment