0

So I struggled a bit with Apache's mod_rewrite, but finally managed to configure(yes) and understand it(maybe?).

When the user goes to /index they are showed the /index.php page and the browser's url is http://example.com/index.

The user can also go to /index.php and the browser's url is http://example.com/index.php.

RewriteEngine On 
RewriteBase /
RewriteRule ^index$ /index.php
RewriteRule ^$ /index.php

So my question is, how do I redirect a user from /index.php to only /index using only the server's configuration?

Emanuel Vintilă
  • 1,911
  • 4
  • 25
  • 35

1 Answers1

0

I'm not too sure what you mean by this.

in .htaccess to remove the extension .php you can use this:

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

I do believe this:

RedirectMatch 301 (.*)\.php$ http://www.example.com$1

Should work for removing the .php

Maybe try that?

DannieCoderBoi
  • 728
  • 2
  • 12
  • 31