通过htaccess,我想删除url中的这个点:产品/描述示例:https://test.com/Products/Description/logitech/Id-12
我试过这个,但它不起作用。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ Products/Description/$1$2 [L]
下面是我完整的htaccess尝试过的规则文件:
RewriteEngine On
DirectorySlash Off
# Remove WWW
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=302,L]
# Remove Trailing Slashes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)//+[?\s]
RewriteRule ^ %1 [R=302,L]
# Reroute to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
# Remove Products/Description ===> not working
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ Products/Description/$1$2 [L]
1条答案
按热度按时间yyhrrdl81#
根据您展示的示例和努力,请尝试以下.htaccess规则文件。我们需要对它做一些更改。请确保您的.htaccess文件与
Products
文件夹位于沿着(不是在它里面,而是在它旁边)。此外,请确保在测试URL之前清除浏览器缓存。