我知道有很多話題,我嘗試了很多次,但它不起作用。在.htaccess文件中隱藏文件擴展名(php)
我想要什麼? 代替example.com/en/file.php用戶只能看到:example.com/en/file
我的.htaccess:
DirectoryIndex index.php index.html
RewriteEngine on
*RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ /$1.php*
ErrorDocument 404 /index.php
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^ru\/index\.php$ "http\:\/\/example\.com\/ru\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^en\/index\.php$ "http\:\/\/example\.com\/en\/" [R=301,L]
等每種語言
1.我添加了什麼來隱藏擴展?
- 它工作後應該使用頁面之間的鏈接作爲「file.php」或只有「文件」?
檢查'RewriteRule'語法 - 這是相反的。第一個是「重寫什麼」,第二個是「重寫的結果」 – zerkms
這是我見過的最常見的問題,它不會在發佈之前進行搜索 –
這就像黑客攻擊,使用簡單的PHP框架總是更好。嘗試[CodeIgniter](http://ellislab.com/codeigniter)或[CakePHP](http://cakephp.org/)如果你想給它一個鏡頭:) –