Question Detail

How to remove index.php from URL where website hosted on AWS ec2 Server PHP Website?

1 years ago Views 511 Visit Post Reply

My website is hosted successfully on AWS ec2 Instance but while visiting a website other than the home page it shows me a 404 page Not found, But if I add index.php in the URL it starts working something like this:

example.com/about-us =>404 PAGE NOT FOUND

example.com/index.php/about-us => WORKING FINE

I have added some code in the .htaccess file but still no change in the flow, it was working for other server but not on AWS Linux server.

Please help me out


Thread Reply

Hemant Sharma

- 1 years ago

Add this code in the htaccess file and follow given below steps:

<IfModule mod_rewrite.c> RewriteEngine On #RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] </IfModule>

 

Steps to remove index.php from url on Amazon-ec2 AMI (instance only)

  1. Connect your instance using Filezila or WinSCP and open directory /etc/httpd/conf/ and your can see httpd.conf file .
  2. Now check it permission by right click on file>File permissions.
  3. IF your file permission is other than 777 then it won't work to change permission follow further steps or jump to step 6.
  4. To change file permission connect your instance using PUTTY or any other terminal but i am using PUTTY.
  5. Run this command to change it's permission sudo chmod 777 /etc/httpd/conf/httpd.conf.
  6. Now your can open httpd.conf file and edit.
  7. Jump to line no 151 and change AllowOverride None to AllowOverride All.
  8. And it's done just change it's permission to default using this command sudo chmod 644 /etc/httpd/conf/httpd.conf. 9.Don't forgot to restart services using this command sudo service httpd restart

Hemant Sharma

- 1 years ago

Add this code in the htaccess file and follow given below steps:

<IfModule mod_rewrite.c> RewriteEngine On #RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] </IfModule>

 

Steps to remove index.php from url on Amazon-ec2 AMI (instance only)

  1. Connect your instance using Filezila or WinSCP and open directory /etc/httpd/conf/ and your can see httpd.conf file .
  2. Now check it permission by right click on file>File permissions.
  3. IF your file permission is other than 777 then it won't work to change permission follow further steps or jump to step 6.
  4. To change file permission connect your instance using PUTTY or any other terminal but i am using PUTTY.
  5. Run this command to change it's permission sudo chmod 777 /etc/httpd/conf/httpd.conf.
  6. Now your can open httpd.conf file and edit.
  7. Jump to line no 151 and change AllowOverride None to AllowOverride All.
  8. And it's done just change it's permission to default using this command sudo chmod 644 /etc/httpd/conf/httpd.conf. 9.Don't forgot to restart services using this command sudo service httpd restart