0

I got a Linux CentOS 6 x64 VPS and I installed a website on it. I do not have a rich experience with Linux, however I successfully installed Apache and my website, which is a game panel to control my gaming servers. The website was installed in a subfolder of the var/www/html folder. The issue is that I cannot get rid of the Apache default template. I tried adding a .htaccess file in var/www/html to redirect to my community's website, so the template won't show up, but it didn't work.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^104.255.97.113 [NC,OR]
RewriteRule ^(.*)$ http://www.ad-rp.xyzt/$1 [L,R=301,NC]

Do you have any suggestions?

0

By default template, do you mean the "It works!"-page you see when you do a fresh installation of Apache 2.x? If so, then you simply have to move/remove the files or change the ghost (000-default.con) in /etc/apache2/sites-available.

If the files are not located in /var/www/html, which they should by default if I recall correctly, then you could execute the following command to locate them, note that updated should be ran as root or with sudo!:

sudo updatedb
locate html/index.html

This should return all locations where html/index.html was found, and is most likely the default "It works!"-page you are currently receiving on your web server. You'll still have to find out which one exactly is the one that is being rendered, but that can be found in the default vhost-configuration-file. Try executing the following command:

locate 000-default.conf

This should return the exact location of the default vhost-file. You'll probably see 2 locations, one in sites-available and one in sites-enabled directory (not this is the default on Debian/Ubuntu destributions, these may vary on CentOS for example). The sites-available has all vhost-configuration-files, you can add new, remove or edit them. The sites-enabled has symlinks to the sites-available, but only of vhost's that are enabled (by executing a2ensite name on Debian/Ubuntu or sybolic link on CentOS (sudo ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/example.com.conf)). If you do not have this default vhost-file or locations (sites-available and sites-enabled) on your system (probably on CentOS and distributions other then Debian/Ubuntu), you can edit your httpd-config file (default location: /etc/httpd/conf/httpd.conf) and add "IncludeOptional sites-enabled/*.conf" at the end of the file. This will put alle enabled vhosts into this particular directory. Make sure it exists!

You can check either version of the file, as they are exactly the same. You can do this by executing:

cat /path/to/file/000-default.conf | grep DocumentRoot

This should output the DocumentRoot included in that file. This is the root directory of this particular vhost, and in which you'll find your template-files.

But as I mentioned, the default location should be /var/www/html/, which is where you uploaded your website already. Is it possible that your website has a index.php and no index.html, as this would not override the default template file, thereby causing the web server to still return the index.html template instead. You can fix this by changing the DirectoryIndex in your apache2.conf-file.

  • Thanks! I also placed files in the /var/www/html folder and now there are no issues. – Mihai Berbece Jan 6 '16 at 14:30
  • Glad to help. If your issue is resolved, please select the working answer (press the V-symbol). – Qlii256 Jan 6 '16 at 16:49
  • Your answer is quite debian/ubuntu-specific. CentOS puts config files in /etc/httpd/conf/ and /etc/httpd/conf.d/, and there are no sites-available or sites-eneabled directories. – jsbillings Jul 9 '16 at 16:27
  • You're right, jsbillings. I didn't know that because I'm not familiar with CentOS. But it appears that the TS has solved his/her issue reading from his/her last comment. I shall update my answer. – Qlii256 Jul 9 '16 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.