0

My .htaccess file currently has -

RewriteEngine On

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

# remove .html
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)/?$ $1.html [L]

Since I have two files (login.html and login.php), when I do /login, it automatically goes to the php.

In a javascript file, I have it redirecting to /login, but I need it to redirect to login.html, not login.php. How do I do that without doing /login.html because I still want to hide the extensions from the website url. Similarly, how would I redirect to either sites without the extensions? Is it possible or do I need to create different names for them.

Billie
  • 11
  • 4
  • you can do it by redirecting the request with php https://stackoverflow.com/questions/768431/how-do-i-make-a-redirect-in-php here you are how to do it – Afshin Izadi Aug 02 '19 at 18:17
  • Have you try to swap htaccess rule order? html in the top and php bottom – William Gunawan Aug 02 '19 at 18:20
  • I don't understand, in the Javascript file, who exactly are you hiding the extension from? – GrumpyCrouton Aug 02 '19 at 18:24
  • you should try to find out if this request is from javascript in your htaccess file, to do this I think you should set an parameter that you could detected it is a javascript request, for example you can set the url in you javascript code as index.html?type=js and then you should rewrite your rules in htaccess file, – Afshin Izadi Aug 02 '19 at 18:32

1 Answers1

0

Since you're essentially stripping the extension, you would need different file names for them.

Pat
  • 78
  • 2
  • 14