我知道有很多话题,我尝试了很多次,但它不起作用。在.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/)如果你想给它一个镜头:) –