Redirect to home page on 404 – htaccess

How to redirect to home page on page not found 404

If you have a page that is not found, then google and others will penalize your site for not finding the page. Hence, you should handle that internally.

At least the easiest thing one can do is to redirect the site to the home page using .htaccess directives.

Homepage redirection 404

First create a .htaccess file if you don’t have one yet. Place this .htaccess file in the root of the website.

Then add the following line in the .htaccess file.


Options -MultiViews
RewriteBase /
RewriteEngine On
#if you have other redirect rules, have them here
#put this at the end of the file.
ErrorDocument 404 /

Mind you, the page you are going to redirect to should be relative path.
On the above file, those starting with # are comments and won’t be read by the server.

Hope it helps. Let me know if this helps you or if you have better method by leaving the comment down.

airplane in he runway

Deploying Symfony on Production Server

Time to ship your symfony app to production? Here are some flight checks. Lets assume your symfony app is in folder symfony-app

1. Don’t put Symfony app in the public accessible folder on your server

If your servers public facing folder is, say, /var/www/html, then don’t put the whole symfony folder there.

Choose another deeper and non-public facing folder. Let say /apps/symfony-app. I will list how you would put the public facing folders later.
For this to happen run this command on your server

mkdir /apps

2. Pushing your code to production server

You can use FTP client like filezilla or cyberduck and put your code in /apps
If you are using git, then you can clone your app like this

cd /apps
git clone https://username@bitbucket.org/username/symfony-app.git symfony-app

Continue reading Deploying Symfony on Production Server

Apache listing directory – I swear I have index file!

OK, the ultimate wisdom is you will put your index file on the webserver accessible directory and your website would be visible – right? Well, not all the time.
Apache might decide to list your files even though you put your index.php in the directory you are expecting..
The thing lies on the default configuration of your server. If the default http.conf file has the directory setting to list then it will list even in the virtual hosts.
The fix Add your DirectoryIndex

So typical .htaccess or your setting in http.conf file would look like

...you other configs
   DirectoryIndex index.php //or whatever you want it to start from 
....your other configs

vOILa