2014-09-19 28 views
-1

我需要重定向的URL像這樣:Blogger.com重定向網址 - 如何?

http://domain.com/2014/08/post1-url.html 
http://domain.com/2014/05/post2-url.html 
http://domain.com/2013/04/post3-url.html 

到:

http://domain.com/post1-url 
http://domain.com/post2-url 
http://domain.com/post3-url 

任何人可以幫助,告訴我什麼,我需要在我.htaccess文件寫?謝謝!

我這個嘗試過,但它不工作:(前6行是從WordPress的)

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 

RewriteRule ^domain.com/(.*)/(.*)/(.*)\.html$ domain.com/$3 [R=301,L] 
</IfModule> 

回答

2

您可以使用:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

RewriteRule ^\d{4}/\d{2}/(.+?)\.html$ /$1 [R=301,L,NE,NC] 

RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 

</IfModule> 

你的正則表達式是不正確的,你無法匹配RewriteRule中的主機名。