0

I need your help.

I would like to redirect all files in a specific folder to redirect from .php to no extension. I tried to change htaccess, but it does not work. I only want the files in the hotels folder to be redirected. I have not yet found a proper solution here at stackoverflow .

mysite.com/hotels/london.php &

mysite.com/hotels/new-york.php

to

mysite.com/hotels/london &

mysite.com/hotels/new-york

What would be the appropriate redirect so that if someone clicks one of the .php URLs, they are redirected to the extension-less URL. I would greatly appreciate your help.

Community
  • 1
  • 1
Max Scho
  • 49
  • 1
  • 7

1 Answers1

1

Use this in .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]

make sure mod_rewrite installed.

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
Ayush Ghosh
  • 487
  • 2
  • 10