仅向 .php 文件扩展名添加斜线
Add slashes to .php file extensions only
我的 htaccess 代码在所有 URL 的末尾添加了一个斜线,但我只想将斜线添加到以 .php 文件扩展名结尾的文件,我该怎么做?
我的 htaccess 代码:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^\/(.*?)\/$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L,NE]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ .php [NC,L]
能否请您尝试以下。仅使用显示的示例编写。请确保在测试您的网址之前清除浏览器缓存
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.php$ [NC,OR]
RewriteCond %{REQUEST_URI} ^/seo$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L,NE]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ .php [NC,L]
我的 htaccess 代码在所有 URL 的末尾添加了一个斜线,但我只想将斜线添加到以 .php 文件扩展名结尾的文件,我该怎么做?
我的 htaccess 代码:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^\/(.*?)\/$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L,NE]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ .php [NC,L]
能否请您尝试以下。仅使用显示的示例编写。请确保在测试您的网址之前清除浏览器缓存
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.php$ [NC,OR]
RewriteCond %{REQUEST_URI} ^/seo$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L,NE]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ .php [NC,L]