too long

I have a php file which is home.php

my url on localhost is

http://localhost:8888/photo/home.php

I want to remove .php from the url

so i create .htaccess file

RewriteEngine On

RewriteRule ^home?$ home.php

but i keep getting this error

The requested URL /photo/home was not found on this server.

Try it like this, in your photo directory.

RewriteEngine On

# neither a file nor a directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^home$ home.php [QSA,L]

First of all, ensure your .htaccess file is in the base directory of your project. Next, follow these htaccess rules to set up your redirect.

The .htaccess solution you might be looking for is:

RewriteEngine On

#Neither a file nor a directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^photo/home$ photo/home.php [QSA,L]

I got this problem when I put the .htaccess code in the root .htaccess. It works when I create a new .htaccess in the subdomain folder on the same level with public_html folder and fill it with the RewriteRule needed