0

I've looked up and tried 3 or 4 answers on SO for this and they are not working for me.

I have dev.mydomain.com/pw/ and I want dev.mydomain.com/pw/builder to redirect to dev.mydomain.com/pw/builder.php etc.

I have tried several solutions including:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]

from: here and:

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

from: here

as well as:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ $1.php [L]

that I have from other projects.

I have also tried manipulating the RewriteBase to various things, like / and /pw/ to no effect.

Anything obvious I'm doing wrong/not doing?

Community
  • 1
  • 1
sharf
  • 2,123
  • 4
  • 24
  • 47

1 Answers1

0

Place this rule in /pw/.htaccess:

RewriteEngine On
RewriteBase /pw/

RewriteCond %{THE_REQUEST} /(?:index)?(.*?)\.php[\s?] [NC]
RewriteRule ^ %1 [R=301,L,NE]

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