I have inherited a webserver already serving some websites. I am trying to migrate some of those sites to a new webserver.
One of those websites has a page called:
http://mydomain/ABCDepartment/
This URL also works:
http://mydomain/~joesmith
and the index page for joesmith actually lives in /var/www.../ABCDepartment/people/joesmith/
Now I am checking in httpd.conf and I see the following:
UseCanonicalName Off
UserDir public_html
UserDir disabled root
There are no special mod_rewrite rules for joesmith or the ~
How is this magic happening? UseCanonicalName is off, and if it wasn't UserDir public_html should look in /home/joesmith/public_html
What am I missing?
This is an Apache extension called userdir: http://httpd.apache.org/docs/1.3/mod/mod_userdir.html
It automatically rewrites requests to point to a folder called public_html within the user's home directory (the web server must have read access up the tree to this folder).
Related
I've created a new domain and setup a php application on the webroot. All the following requests are working perfectly.
/index.php
/info.php
/?anyting ( Note this, without index.php only query string is working )
/css/app.css
Only the domain's root is not working domian.in
I have created an virtual host for the domain. I tried giving DirectoryIndex index.php also, but still it's not working. There is no htaccess and it's a fresh server setup.
Googled whatever was possible, couldn't get any solution.
And if i hit domain.in it's serving the apache's default page.
If you have an virtual host you cant acces files outside the document root.
Maybe your html files (or others) are in a htdocs folder or something, you cant access htdocs/../
I have an apache server with some websites built in Wordpress, using vhosts.
The thing is that I have for all of them a configuration like:
ServerName site1.com
ServerAlias www.site1.com
When I access to Site1 through "site1.com" the URL changes to "www.site1.com". The same for Site2, Site3, etc. But for SiteN it's inverse. If I access to "siten.com" it keeps the URL and if you go to "www.siten.com" it changes to "siten.com".
I know I can change this using htaccess file, but my doubt is why some sites has a default and the new site has another default? All the htaccess have the same things and the vhost configuration is the same for all.
Thank you,
Done! The change should be implemented in Wordpress configuration, is not a htaccess issue
I have a web setup where there are multiple sites under one directory... and one media folder containing images for each site...
www.domain1.com/media/domain1.com/
www.domain2.com/media/domain2.com/
As you can see domain1.com's media can be accessed from domain2 e.g. www.domain2.com/media/domain1.com/
and vice versa...
I want to restrict domain1 to access /media/domain2.com/ folder can it be done via htaccess file?
my idea was to somehow read the domain name and match it with the directory its trying to access...
or
alternatively can redirect all requests in media folder to a php script that can do the matching...?
Use VirtualHost for each domain and specify DocumentRoot for them, it will also remove the /media/domainN/ from URL.
If you want to perserve the document root for some reason, try using this in each VirtualHost directive:
<Directory "full/path/to/media/domain1.com">
deny from all
</Directory>
and vice-versa for domain2.
I have a http.//domain.com served at /var/www/domain
I also a http.//subdomain.domain.com served at /var/www/domain/subdomain
When a user visits http.//subdomain.domain.com i want apache to serve /var/www/domain
I have been looking everywhere and have found solutions from within the virtual hosts declarations with an Alias
But as I am on a shared host, I cannot edit httpd.conf.
So i have to do it from .htaccess
The important part here is to not redirect the user, only serve the main domains directory from an htaccess.
Here is the folder layout.
/outside is not normally accessible anywhere on example.com
/public_html is the folder for http://example.com
How can I use Apache's htaccess to make the url http://example.com/outside/ to show content from the folder /outside?
Thanks!
How can I use Apache's htaccess to make the url http://example.com/outside/ to show content from the folder /outside?
You can't. As far as I have found out, Apache prevents directives in .htaccess files linking to locations outside the current web root.
You would have to do this in the central configuration:
Alias /outside /path/to/your/outside
You may be luckier with a symlink if you can turn FollowSymLinks on.