0

I would like to have the filename including the extension not show in the URL when requesting it. And I am wondering is this possible with a PHP & Apache combination - and how can this be achieved?

For example, this:

www.domain.com/folder/filename.php

Should become, this:

www.domain.com/folder/

Any suggestions?

Cyclonecode
  • 29,115
  • 11
  • 72
  • 93
Carpet
  • 527
  • 2
  • 10
  • 17

1 Answers1

3

The following rule in an .htaccess file will work:

RewriteRule ^folder/$ folder/filename.php [L]

A more dynamic rule that will rewrite folder/<filename> to folder/filename.php would be:

RewriteRule ^folder/(.*[^\.php])$ folder/$1\.php [L]

Reference

mod_rewrite

An In Depth Guide to mod_rewrite for Apache

Cyclonecode
  • 29,115
  • 11
  • 72
  • 93