Changing Apache directives on GoDaddy shared server - html

The site I'm working on is hosted on GoDaddy's shared servers. I need to increase the limit on the Apache directive LimitRequestBody. I've tried adding the following to .htaccess:
LimitRequestBody 20250000
But that doesn't have any effect. I've called GoDaddy support several times, and nobody there seems to know how to help.
Any ideas?

Make sure your .htaccess file is affecting the correct directory - the one where the script you want to limit lives. To affect only that directory, put your .htaccess file in the root directory(above your script) and wrap your directive with
<Directory "/var/www/path/to/script">
LimitRequestBody 20250000
</Directory>
After you change the .htaccess file, you need to run
# service httpd reload
I hope this helps.

Related

How do I make a custom 'File not found(404, 500)[http error code]'for my website

I have seen some websites have their own File not found pages with their logos.
I want such a page for my website.
Please tell me how to make a such type of page that shows the user if the file is not found.
First of all you need an HTML or PHP file to show when the 404 is occurs. Let's do a simple HTML file like this:
<h2> 404 Not Found! </h2>
<pre> Seems like the resource you're looking for is not found </pre>
Let's call this file 404.html.
Now you have to configure your webserver to redirect the not found request to your new HTML document.
If you're using Apache:
You can do it in different ways, the most common and recommended would be using .htaccess file, which allows you to override Apache configuration of a virtual host. However, to be able to use the .htaccess file in your virtual hosts you need to add allowOverride all inside your apache configuration.
Example of apache config:
<Directory /path/to/your/project>
Options FollowSymLinks
AllowOverride All # This is the needed option
Order allow,deny
Allow from all
Require all granted
</Directory>
So now you're able to put a .htaccess file in your project, so just create it and put this inside:
ErrorDocument 404 /path/to/404.html/document
In case you're using Nginx:
You must add the error page inside the nginx configuration. Follow this guide in order to achieve it:
https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-to-use-custom-error-pages-on-ubuntu-14-04
if you are using Apache server
in your project folder
consider your project is in
/mySampleProject
create .htaccess file in /mySampleProject if you don't have one.
simply add this line in your .htaccess
ErrorDocument 404 /yourCustom404Template.html
I will suggest you, use a framework of whatever programming language you want to build this application. They have in-built custom arrangements for such requirement e.g.
if( file_not_found Logic ){
show 404_page
}

My website doesnt load index.html if i dont write it manually

I recently bought a website to play with, but I immediately had a problem.
My website doesn't load the index.html when I just connect to mydomain.com. If I write it manually (mydomain.com/index.html) everything works perfectly. I tried to change the .htaccess file to direct all traffic to my index.html page with the following line, but the problem remains:
DirectoryIndex index.html
Any ideas to solve the problem?
Please provide the web host and/or server type (windows, linux, etc) to help further answer your question.
As a start some web servers (windows/iis) expect different file names for the default html file. Godady.com has a list of different file names for Linux and Windows at this url: https://www.godaddy.com/help/what-file-displays-when-someone-browses-to-my-domain-name-60
Good luck!
This DirectoryIndex index.html has to be set in httpd.conf file. In your httpd.conf, you might have disabled .htaccess with AllowOverride none. That is why your .htaccess is not working

How to fix website internal navigation/ Joomla

I have a situation to which I cannot seem to have a fix for !
The thing is I'm hosting a website on localhost (LAMP).
The website is created using Joomla Framework. The home page loads successfully when I navigate to the website on the localhost.
As soon as I click on any navigation links, a 404 error is displayed.
eg. homepage URL -
http://localhost/PortalSources/
Nav link -
http://localhost/PortalSources/tools/safety-assessment-tool.html
As soon as I manually add 'index.php' to the nav link
http://localhost/PortalSources/index.php/tools/safety-assessment-tool.html
the link starts to work and page loads successfully.
What could possibly cause this behavior ? How do I fix it so that I don't have to manually type in for every page on the website ?
You can probably find your answer here: https://docs.joomla.org/Enabling_Search_Engine_Friendly_(SEF)_URLs
Verify .htaccess is Enabled
Check that your Apache config file allows .htaccess overrides. You must make sure overrides are enabled or the .htaccess file in your Joomla! root directory will be ignored or cause an error. In the section of your virtual host configuration file or in the main (httpd.conf) configuration file you must have something similar to the example below enabling overrides:
<Directory "/home/user/public_html">
AllowOverride All
</Directory>
<Directory "/path/to/htdocs">
AllowOverride All Options=[an option],[an option],...
</Directory>
There are other ways to test if .htaccess is enabled if you do not have access to your site's configuration files. Please refer to the .htaccess tutorial found on The Apache Software Foundation website for additional information.
Step by Step
These are step-by-step instructions. Please follow them in the order they are presented here. If a step fails, do not continue until you have solved the problem.
Rename the file "htaccess.txt" in your Joomla!'s base folder to ".htaccess".
This step may not be necessary. Open .htaccess in a text editor. Uncomment RewriteBase / (remove the first character, #). If Joomla is installed in its own folder, the enter the Joomla folder name after the backslash. e.g. RewriteBase /yourjoomlafolder.
Log on to your Back-end and open the Global Configuration.
Enable the Use Apache mod_rewrite/URL rewriting option and Save. This option uses the Apache mod_rewrite function to eliminate the "index.php" portion of the URL.
Check if your site works correctly. Your URLs should now look like:
http://www.example.com/the-­news/1­-latest-­news/1-­welcome-­to­-joomla
If this option causes errors, please see How to check if mod rewrite is enabled on your server.
If it is not enabled and you have access to the file apache/conf/httpd.conf, open that file and check if the line LoadModule rewrite_module modules/mod_rewrite.so is uncommented. If necessary, uncomment the line and restart the Apache web server.
If mod_rewrite cannot be enabled, leave this option off. It does not matter if you leave the .htaccess file renamed.
If you think this necessary, enable Add suffix to URLs and Save. This option adds .html to the end of URLs. There are different opinions on whether this is necessary or even useful. Search engines do not seem to care if your URLs end in .html or not.
Open the Plugin Manager and enable the System - SEF plugin. This plugin adds SEF support to links in your Joomla articles. It operates directly on the HTML and does not require a special tag.

LAMP - make directory accessible only to certain web pages

I am tinkering around with webpages on a LAMP server running Apache2 and was wondering if it was possible to make a directory accessible only to your web pages and not from outside?
Example scenario:
Directory to protect: dir1 containing images (jpg, png)
My own webpage: mypage.html that calls images from dir1
My website: www.myweb.com that contains both dir1 and mypage.html
Currently, files inside the website can be accessed via www.myweb.com/dir1/somefile.jpg or by calling mypage.html
I would like it to only be accessible by calling mypage.html
I have tried the following:
modifying .htaccess to disallow access of image types
<files "*.jpg">
deny from all
</files>
(doesn't work because mypage.html cannot access it either)
Modify apache2 conf file with:
<Directory /var/www/dir1>
AllowOverride None
<Limit GET POST OPTIONS>
Order deny,allow
Deny from all
</Limit>
</Directory>
(this actually semi-worked as it allowed me to write to directory but not read, maybe this can be modified to allow requests coming from internal web pages to go through?)
I guess to conclude, is there a way to get Apache2 to ONLY accept requests to access a directory if it is of a certain url of your choosing?
Thanks in advance.
So, I've decided that the approaches I've taken so far really don't cut it and found you could actually call a php function where
<img src='somefile.php?query=xxx' alt='pic'>
and where in the somefile.php I have that takes in img file name created from the query above.
echo file_get_contents($imgresource);
By serving the image from a php script and blocking this php script from being called without proper credentials, sessions, cookies and IP blocking, there is some security set.
So I guess it doesn't really answer the question in its entirety of blocking access only to some URLs but it works for the purpose of not being able to be accessed externally since I have buried the directory below (or above?) the web root directory where it can't be called from a url and only from internal script.

How do I change the default index page in Apache?

I would like to change the default web page that shows up when I browse my site. I currently have a reporting program running, and it outputs a file called index.html. I cannot change what it calls the file. Therefore, my landing page must be called something else. Right now, when I browse my site it takes me to the reporting page.
From what I see, whatever you call index.html it will pull that up as your default. I want to change that to landing.html. How do I do this?
I am a folder (Folding # Home). The reporting program is HFM.net. HFM can output an html file with my current folding statistics. It names the html file index. I do not want that to be my default home page. I would like a menu-like landing where I can choose if I want to see my stats, or something else. The website is at /home/tyler/Documents/hfm/website (landing.html and hfm's index.html are here). Apache2 is in its default directory.
I'm also running Ubuntu 13.04.
I recommend using .htaccess. You only need to add:
DirectoryIndex home.php
or whatever page name you want to have for it.
EDIT: basic htaccess tutorial.
1) Create .htaccess file in the directory where you want to change the index file.
no extension
. in front, to ensure it is a "hidden" file
Enter the line above in there. There will likely be many, many other things you will add to this (AddTypes for webfonts / media files, caching for headers, gzip declaration for compression, etc.), but that one line declares your new "home" page.
2) Set server to allow reading of .htaccess files (may only be needed on your localhost, if your hosting servce defaults to allow it as most do)
Assuming you have access, go to your server's enabled site location. I run a Debian server for development, and the default site setup is at /etc/apache2/sites-available/default for Debian / Ubuntu. Not sure what server you run, but just search for "sites-available" and go into the "default" document. In there you will see an entry for Directory. Modify it to look like this:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Then restart your apache server. Again, not sure about your server, but the command on Debian / Ubuntu is:
sudo service apache2 restart
Technically you only need to reload, but I restart just because I feel safer with a full refresh like that.
Once that is done, your site should be reading from your .htaccess file, and you should have a new default home page! A side note, if you have a sub-directory that runs a site (like an admin section or something) and you want to have a different "home page" for that directory, you can just plop another .htaccess file in that sub-site's root and it will overwrite the declaration in the parent.
You can also set DirectoryIndex in apache's httpd.conf file.
CentOS keeps this file in /etc/httpd/conf/httpd.conf
Debian: /etc/apache2/apache2.conf
Open the file in your text editor and find the line starting with DirectoryIndex
To load landing.html as a default (but index.html if that's not found) change this line to read:
DirectoryIndex landing.html index.html
I had a similar problem. When providing http://server/appDirectory I got a directory listing instead of index.html even though I had
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
in my httpd.conf file.
My solution was to uncomment the
LoadModule setenvif_module modules/mod_setenvif.so
line in httpd.conf
Apache version: 2.4
In Ubuntu you can add in file:
/etc/apache2/mods-enabled/dir.conf
line
DirectoryIndex myhomepage.htm
and then restart apache service
sudo systemctl restart apache2
In Unbuntu, you can update the default page on a site-by-site basis with the site config files eg:
/etc/apache2/sites-available/your.domain.conf
Same syntax for the key line in the file, eg mine is;
DirectoryIndex default.htm index.htm
Then don't forget to enable and reload:
sudo a2ensite your.domain.conf
sudo systemctl reload apache2