.htaccess; no extension required

前端 未结 3 788
迷失自我
迷失自我 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:17

    You can write a rewriting rule which only takes into effect if the requested file doesn't exists.

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

提交回复
热议问题