.htaccess从URL中删除子目录

.htaccess从URL中删除子目录,.htaccess,.htaccess,我有一个网址: "http://www.example.com/pages/about.html" 我已经能够去掉文件扩展名,并在末尾添加“/”以创建: "http://www.example.com/pages/about/" 使用: RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.html RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html RewriteCond %{REQUEST

我有一个网址:

"http://www.example.com/pages/about.html"

我已经能够去掉文件扩展名,并在末尾添加“/”以创建:

"http://www.example.com/pages/about/"

使用:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.html
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
接下来,我需要从URL中删除pages子目录文件夹,以便获得:


"http://www.example.com/about/“

如果您不想在服务之前使用/services/,则必须将服务页面移动到其他文件所在的“页面”文件夹中,然后替换

RewriteRule ^([^/]+)/$ $1.html
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html


不可能。。您可以获取/services/service1/和/about/,但不能获取/service1/和/about/。您需要在service1之前保留/services/,否则它会断开,我会将services文件夹中的所有内容添加到pages文件夹并删除services文件夹。我应该将什么代码添加到.htaccess文件中,并将其放在当前代码之前还是之后?
RewriteRule ^([^/]+)/$ /pages/$1.html