1

Good day!

I want to make proper redirect by htaccess, when there is GET request like this:

example.org/directory/page/

It should give example.org/page.php

My htaccess lets only redirect this kind of request

example.org/directory/page

I use this config

#remove extension
RewriteRule ^([^\.]+)$ $1.php [NC,L]
#remove directory
RewriteRule ^directory/(.*)$ /$1 [L]

Thank you for attention!

anubhava
  • 761,203
  • 64
  • 569
  • 643
Sabine
  • 323
  • 4
  • 14

1 Answers1

0

Reorder your rules and tweak .php adding rule:

#remove directory
RewriteRule ^directory/(.*)$ /$1 [L]

#remove extension
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^([^.]+)/?$ $1.php [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643