我是使用 htaccess 的初学者,我不知道如何做我想做的事。我想了解我在做什么,所以如果您能帮我给我一些建议(非常!)初学者,我将不胜感激... :) 我想: 将 xxx.php、xxx.html 或任何扩展名重定向到 xxx(无扩展名) 现在,我的 htaccess 是
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
它有效,但只要我写 xxx。但是,如果我写 xxx.php(我看到页面 :(,我想重定向到 xxx),如果我写 xxx.html,它什么也不会显示。
最后。我想将变量重写为友好链接 即如果我有 xxx.php?id=1 > 我想重定向到 xxx/username
提前谢谢你 最良好的祝愿和圣诞快乐! :)
最佳答案
试试这个:
I use this code already.
Rule:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>
Put this in your htaccess file && then check for files without extension.
谢谢
关于.htaccess - htaccess 无扩展名重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20763701/