.htaccess htaccess无扩展重写
我是一个使用htaccess的初学者,我不知道如何做我想做的事情。我想了解我在做什么,所以如果你能帮我给ver(非常!)初学者一些建议,我将不胜感激…:) 我想: 将xxx.php、xxx.html或任何扩展重定向到xxx(无扩展) 现在,我的访问权限是.htaccess htaccess无扩展重写,.htaccess,mod-rewrite,redirect,seo,friendly-url,.htaccess,Mod Rewrite,Redirect,Seo,Friendly Url,我是一个使用htaccess的初学者,我不知道如何做我想做的事情。我想了解我在做什么,所以如果你能帮我给ver(非常!)初学者一些建议,我将不胜感激…:) 我想: 将xxx.php、xxx.html或任何扩展重定向到xxx(无扩展) 现在,我的访问权限是 RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php 这是可行的,但只要我写xxx就行了。但
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
这是可行的,但只要我写xxx就行了。但是如果我写xxx.php(我看到页面:(,我想重定向到xxx),如果我写xxx.html,它不会显示任何内容
最后,我想将变量重写为友好链接
i、 e.如果我有xxx.php?id=1>我想重定向到xxx/username
先谢谢你
祝您圣诞快乐!:)尝试将这些规则添加到您的htaccess文件中:
RewriteCond %{THE_REQUEST} \ /+([^\?\ ]+)\.php
RewriteRule ^ /%1 [L,R=301]
如果需要对.html
扩展执行相同的操作,请将该条件的php
部分更改为(php | html?
)尝试以下操作:
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.
我已经在使用这个代码了。
规则:
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写规则^([^\.]+)$$1.php[NC,L]
将其放入htaccess文件&&然后检查没有扩展名的文件。
谢谢谢谢!成功了!;)您的代码使页面在没有扩展的情况下打开,但它不会将say
about.php
重定向到OP要求的about