1

I've uploaded a php script to my online server, how can I route to pages without using .php extension?

The script is running on AWS, Ubuntu 18, PHP 7.2.19, Apache 2.4.29 I've tried to use .htaccess, installed and enableed mod_rewrite, but it didn't work.

.htaccess file:

IndexIgnore * # prevent directory listing

Order deny,allow
Allow from *

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

apache2.conf file:

<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

when i route to file like "https://domainname.com/login", I expect to load "login.php" file, which resides in the root application folder, but instead I get 404 not found error:

Not Found
The requested URL /login was not found on this server.

and when navigate to "https://domainname.com/login.php", it works fine.

  • What, where does the `/admin` come from all of a sudden? I’d recommend that you enable rewrite logging, and try and figure out where it goes wrong that way. – misorude Aug 02 '19 at 09:59
  • @misorude i'm trying to navigate to the admin area, and got /admin, I'll edit the question so it becomes consistent. – Mohammed Anghabo Aug 02 '19 at 10:17
  • Possible duplicate of [Removing the .php extension with mod\_rewrite](https://stackoverflow.com/questions/4908122/removing-the-php-extension-with-mod-rewrite) – ThomasVdBerge Aug 02 '19 at 11:08

0 Answers0