1

I want to redirect pages without extension to a php file. E.g.
https://example.com/starrysky/ => https://example.com/starrysky.php
I already have a working redirect from HTML to PHP:
https://example.com/starrysky.html redirects correctly https://example.com/starrysky.php .

When I redirect .html to .php in .htaccess it works flawlessly: it redirects .html to .php, so I thought, replacing the final .html$ by /$ (ending with a slash) would redirect to php but that did not work.

This does work

RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php

But this does not:

# RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)/$ $1.php

Prepending a backslash to the slash + dollar in the last line won't help. And uncommenting the RewriteCond line above won't help me either.

I'd like that https://example.com/starrysky/ redirects to https://example.com/starrysky.php.

It does, but the css, js and images are not loaded, despite being relative to the same document root.

Stphane
  • 3,368
  • 5
  • 32
  • 47
php and js
  • 867
  • 1
  • 6
  • 13
  • 3
    Possible duplicate of [Remove .php extension with .htaccess](https://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess) – Qirel Jun 29 '19 at 12:07

0 Answers0