.htaccess 从htaccess中删除斜杠

.htaccess 从htaccess中删除斜杠,.htaccess,redirect,url-rewriting,http-status-code-404,slash,.htaccess,Redirect,Url Rewriting,Http Status Code 404,Slash,对不起,我的英语不好,但我正在使用翻译。。 我应该删除(并重定向)所有带斜杠的url到不带斜杠的url 问题是,保留斜杠会将我重定向到404页面,但现有页面也没有css(如果存在斜杠,则现有页面会给我404错误) RewriteCond%{HTTP:X-Forwarded-Proto}!https 重写cond%{HTTP_HOST}^www。 重写条件%{HTTPS}关闭 重写规则^https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301,NE] 错误文档4

对不起,我的英语不好,但我正在使用翻译。。 我应该删除(并重定向)所有带斜杠的url到不带斜杠的url

问题是,保留斜杠会将我重定向到404页面,但现有页面也没有css(如果存在斜杠,则现有页面会给我404错误)

RewriteCond%{HTTP:X-Forwarded-Proto}!https
重写cond%{HTTP_HOST}^www。
重写条件%{HTTPS}关闭
重写规则^https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301,NE]
错误文档404/404.html
重新启动发动机
重写基/
重写规则^([^\.]+)$$1.php[NC,L]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)/$/$1[L,R=301]

I通过反复试验(随机)解决

我加了第二部分,你看,但我不明白它的意思。。事实是,它已经就位了

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTP_HOST} ^www.
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]


DirectorySlash Off
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/$ $1 [R=301,L]
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
ErrorDocument 404 /404.html
</IfModule>
RewriteCond%{HTTP:X-Forwarded-Proto}!https
重写cond%{HTTP_HOST}^www。
重写条件%{HTTPS}关闭
重写规则^https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301,NE]
目录删除
重新启动发动机
重写基/
重写规则^(.*)/$$1[R=301,L]
重新启动发动机
重写基/
重写规则^([^\.]+)$$1.php[NC,L]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
错误文档404/404.html

assistenza da remoto
aa
物理目录吗?缺少CSS肯定是因为使用了CSS文件的相对URL路径。。。请参阅网站管理员堆栈上的以下问题:由于已删除最后一个
RewriteRule
指令,最后一部分不再有效
RewriteCond
RewriteRule
指令共同构成一个规则。
ErrorDocument
不应位于
包装中。事实上,您应该删除
包装器(内部有一些指令,外部也有一些指令)。完成后,代码看起来更干净了。然后,从你所看到的,你可以告诉我为什么搜索引擎优化扫描器告诉我我为backupc.it和backupc.it创建了重复页面。搜索引擎优化扫描器是错误的
example.com
example.com/
本质上是相同的URL。严格来说,它是
example.com/
(带斜杠)。但是,如果不一致地链接到两者,则可能会混淆扫描仪。请参阅网站管理员堆栈上的此问题:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTP_HOST} ^www.
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]


DirectorySlash Off
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/$ $1 [R=301,L]
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
ErrorDocument 404 /404.html
</IfModule>