In my linux server my www root of apache server is /var/www/html, I have a folder called blog in the above mentioned path. I have to access the the website in the blog folder by specifying http://myDomain/blog/. My question is I want to be able to access the website by specifying http://myDomain in the browser(without having to move the contents of the blog folder to www root). Is there any parameter which I can set in the config file so as to be able to achieve the mentioned objective.
Thanks.
Edited /etc/httpd/conf/httpd.conf file and search for DocumentRoot and change from
/var/www/html
TO
/var/www/html/blog
In your Apache httpd.conf file, just set the DocumentRoot as being /var/www/html/blog.
Related
I just installed Apaxy for a better and customizable folders views.
It works perfectly, but not in my virtualhost.
Folder (localhost) :
Virtualhost (local.dev.conf, access with local.dev):
<VirtualHost *:80>
ServerName local.dev
DocumentRoot /var/www/local.dev
</VirtualHost>
Unfortunately, in the virtualhost (local.dev) apaxy doesn't work.
I assume it's normal because the server try to find files in local.dev/themes/...
Or my 'themes' folder is in the parent folder, so it is possible to resolve this ?
Here is the .htaccess :
https://justpaste.it/t8yp
Problem
Apache serves file from the directory /var/www/local.dev.
Solution
Moving the directory /var/www/theme into /var/www/local.dev would work. Nevertheless if, for any reason, you do not want to move theme you can link it using the command ln -s /path/to/theme /path/to/local.dev/theme.
IMHO
Moving the directory would be a better solution as linking it, would force the configuration to enable follow-symlink, as it can be considered as a security issue.
I have linux server (Red Hat Enterprise Linux Server release 5.3 (Tikanga)) with apache installed. It is already used for browsing some documents. Now I would like to add a new Directory (with a html page), so whenever the directory is browsed it can display the html page.
But I am not sure of where all to edit the httpd.conf file
Existing httpd.conf:
When I hit the url "http://servername/eng" it displays list of folders.
Now, I want to add a website to this existing, so when user hit the url "http://servername/builds" it should display a html page in the browser.I have added my "index.html" page in location "/var/www/html/builds/"
For this I added the below code to httpd.conf file
Please let me know what all modifications are required in the conf file
You can do it in a few different ways.
Putting index.html in /build
This requires you to have this setting:
DirectoryIndex index.html
(it should be there by default on most platform.)
Also for this to work, rather than putting new <Directory>, you should put the build/ directory in the directory that holds your http://example.com/ files. For instance:
/var/www/example.com/public_html/eng/
/var/www/example.com/public_html/builds/
/var/www/example.com/public_html/builds/index.html
Storing build/ in folder completely unrelated to example.com, but still be able to reach it via example.com/builds
For this, you need to rewrite the URLs so that example.com/builds redirects the user to the final URL. This is most easily achieved through mod_rewrite. You enable mod_rewrite module in your Apache's configuration, make sure that example.com can have .htaccess files through ensuring proper AllowOverride entry in example.com's <Directory> configuration, create /var/www//example.com/public_html/.htaccess (or similar) file, and fill it RewriteEngine On and RewriteRules you need. More on mod_rewrite in the Internet and in the documentation.
Completely separate virtual server, for example builds.example.com/
In this case, what you're looking for are virtual servers. These are not defined in httpd.conf or configuration itself, but usually have dedicated directory.
For example, to add builds.example.com that works for port 80, you'd need to create following entry:
<VirtualHost *:80>
ServerName builds.example.com
DocumentRoot /var/www/builds.example.com/public_html/
</VirtualHost>
Where to put this? Well, it depends on the platform. For Debian, you put this in a new file in /etc/apache2/sites-available/, e.g. /etc/apache2/sites-available/example.com, and symlink to it in /etc/apache2/sites-available (on Debian, you can do this easily with a2ensite <NAME_OF_FILE>. On your platform this procedure might be different, so look it up ("adding virtual servers on " would be a start). After adding virtual servers, you need to reload your Apache configuration.
Please let me know if this satisfies your question, if not, I'll edit the answer accordingly.
I have a subdomain that I want to make the root folder to "Public_html",
for example, my root subdomain is
- /public_html/subdomain
So I want to change that path to just /public_html/ for my subdomain. I know it can be done with .htaccess, but I dont know how to do it. Thanks...
I don't know exactly what you want, but here are my two answers:
Answer 1: You want your DocumentRoot to point to public_html
In this case add/change the DocumentRoot in your (virtual) host config of your webserver (I'm assuming you're using Apache, which would be /etc/httpd/conf/httpd.conf or /etc/httpd/conf/extra/httpd-vhosts.conf or even /etc/apache2/sites-enabled/yourhost)
Answer 2: You want to redirect from your subdomain folder to the root of public_html
This is not possible via a simple RewriteRule due to the fact, that your host is pointing to the subdomain folder. The other way round would possible (redirecting from public_html to subdomain).
What you can to is to create a symbolic link from subdomain which points to public_html or a file in it - but I don't recommend this.
Furthermore resources:
A brief description on how to forward to a subfolder using Rewrite rules
Another brief description about the DocumentRoot
In my application I have separate spaces for user and admin like
if www.example.com is my website, then www.example.com/admin is my admin URL.
I am using a .htaccess file in my root, and it affects some of the functionality in my admin folder, which I don't want to.
For example, consider below is my folder structure
..
.htaccess
index.php
admin
So if I don't want the .htaccess rules to apply within the admin folder, is there any way?
For people that don't have direct access to httpd.conf (shared hosting for example), just put another .htaccess file in the subfolder and set to the desired behavior.
You should be able to do this, but it does require write access to the httpd.conf configuration.
If you have access to the httpd.conf file, something like
<Directory /admin>
AllowOverride None
</Directory
should do the trick.
Also, note that using .htaccess files in the root directory (as you said you did) is not a recommended approach. You'd be better off moving the contents of the htaccess file into the proper contexts of the httpd.conf file.
More information can be found at http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride
I am trying to change the DocumentRoot in httpd.conf from /var/www to /var/www/shop just so I can be organized. But even when I do that after restarting apache and httpd, I go to localhost and it still points to /var/www. My httpd.conf is basically the same as this file here:
http://www.devside.net/guides/config/linux/httpd-conf
I am running this on Debian.
Any ideas? Thanks
Debian uses various include files and a "site" concept, so httpd.conf isn't normally changed at all (the includes are). You likely changed the value before the "default" site changes it back to /var/www.