如何.html从静态页面的URL中删除?
此外,我需要将任何网址重定向到没有网址的网址.html.(即www.example.com/page.html到www.example.com/page).
我想要任何请求,如http://example.com/whatever/index.php301进行重定向http://example.com/whatever/.
我尝试添加:
rewrite ^(.*/)index.php$ $1 permanent;
location / {
index index.php;
}
Run Code Online (Sandbox Code Playgroud)
这里的问题是,这个重写在根URL上运行,导致无限重定向循环.
编辑:
我需要一个通用的解决方案
http://example.com/ 应该提供文件 webroot/index.php
http://example.com/index.php,应该301重定向到 http://example.com/
http://example.com/a/index.php 应该301重定向到 http://example.com/a/
http://example.com/a/ 应该服务于index.php脚本 webroot/a/index.php
基本上,我从不想在地址栏中显示"index.php".我有旧的反向链接,我需要重定向到规范的网址.
我应该添加哪些行以从网站中删除扩展名.html和.php扩展名?
我仅将其用于此.html部分:
RewriteEngine on
RewriteBase /
RewriteCond %{http://jobler.ro/} !(\.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) /$1.html [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+)\.html\ HTTP
RewriteRule ^([^.]+)\.html$ http://jobler.ro/$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)
但我需要将两个文件类型扩展名从同一域中隐藏。