-1

How do I prevent this .htaccess redirect rule in the root from affecting any subdomains?

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

I've tried adding Options -MultiViews +FollowSymLinks per answer to similar q's to no avail.

I also had partial success with RewriteRule ^([^\.]+)$ https://domain.co.uk/$1.php [NC,L] but without the correct condition this still didn't work.

Any help would be massively appreciated.

Toki
  • 517
  • 3
  • 9
  • 27
  • 1
    Add a RewriteCond that checks the host name of the request. https://stackoverflow.com/a/10241757/1427878 – CBroe Mar 28 '23 at 11:35

1 Answers1

0

Per @CBroe's comment the correctly implemented code is as below:

RewriteOptions inherit
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.co.uk$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Toki
  • 517
  • 3
  • 9
  • 27