.htaccess; no extension required

前端 未结 3 791
迷失自我
迷失自我 2020-12-18 04:03

I need some .htaccess code that will treat extensionless files as PHP files.

Suppose the visitors visits www.mywebsite.com/dir1/dir2/file.name, it will

3条回答
  •  一生所求
    2020-12-18 04:31

    Ok, the answer was a combination of answers. I needed to add Options +MultiViews in my Apache configuration. Then I extend Andrews answer to the following:

    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ $1.php [L]
    

    Regards and many thanks! Kevin

提交回复
热议问题