Show file by default, but not extension

I've searched for this all over the place, but can't seem to find a specific solution ...

Basically, I have something similar to the following:

www.thename.co/mpany

I created a page called mpany.php

and set it as my default page and I also added a rule in htaccess so that the file extension is php

not displayed.

My problem is that when you enter www.thename.co

, even if it loads mpany.php

, it displays only the base url No: www.thename.co

in the address bar of the browser, while I would like to show: www.thename.co/mpany

.

Here's my .htaccess

file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
DirectoryIndex mpany.php

      

Any pointers?

+3


source to share


1 answer


You can use these rules in your .htaccess root directory:



DirectoryIndex mpany.php
Options -MultiViews
RewriteEngine On
RewriteRule ^$ /mpany/ [L,R]

# To internally forward /dir/file to /dir/file.php
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]

      

+2


source







All Articles