Roland Miranda
Roland Miranda

Reputation: 21

.htaccess error : The requested URL was not found on this server

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.

Upvotes: 2

Views: 14944

Answers (3)

Aminah Nuraini
Aminah Nuraini

Reputation: 19146

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

Upvotes: 0

Hugo Pakula
Hugo Pakula

Reputation: 385

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]

Upvotes: 2

Abhishek Gurjar
Abhishek Gurjar

Reputation: 7476

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]

Upvotes: 1

Related Questions