1

I'm using Barba in a project with PHP and I want to remove the '.php' extension in the URL.

I tried to change the href of all <a> from /my-page.php to /my-page for example but then I get 2 issues:

  • An error 406 from Barba in the console when I hover the link
  • When I click on the link, the page loads without Barba (no page transition).

I also tried some redirect 301 in the .htaccess file but I get the exact same issues. Here is my .htaccess (redirect found here: https://stackoverflow.com/a/13225718/16478297):

RewriteEngine On

# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]

# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]

I can't find anything in the documentation, is it even possible?

Remy
  • 11
  • 2
  • Does this answer your question? [Remove .php extension with .htaccess](https://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess) – Definitely not Rafal Jul 19 '21 at 07:08
  • @DefinitelynotRafal No, I already tried (see edited question) but It's still not working. – Remy Jul 19 '21 at 08:39
  • Have you also followed the link which says: Possible Duplicate: [Remove .php extension with .htaccess](https://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess), both of those didnt help? You didn link to the URL which i referred to so ill posted the link once again. – Definitely not Rafal Jul 19 '21 at 08:47
  • @DefinitelynotRafal Yes I tried it but it doesn't work with Barba.js. It works fine without Barba.js though. – Remy Jul 19 '21 at 09:07

0 Answers0