2017-09-15 118 views
1

我有一個問題,從一個url中刪除文件夾。我希望Google /舊鏈接不被破壞。舊的網頁有幾個部分,像這樣htaccess刪除文件夾重定向

example.com/news/items/entry1.html 
example.com/news/items/entry2.html 
example.com/blog/items/foo.html 

新頁面的結構具有這樣的URL:

example.com/news/entry1 
example.com/news/entry2 
example.com/blog/foo 

刪除HTML是相當直截了當

<IfModule mod_rewrite.c> 
RewriteEngine On 

# Send would-be 404 requests to Craft 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC] 
RewriteRule (.+) index.php [QSA,L] 

RewriteCond %{THE_REQUEST} /([^.]+)\.html[\s?] [NC] 
RewriteRule^/%1 [R=302,L,NE] 
</IfModule> 

的一部分,我正在努力去除'項目'部分。我發現的規則只適用於請求路徑,如'example.com/items/subfolder1/...'

任何幫助將不勝感激。

回答