我需要帮助来重定向以下网址(在htaccess中)
http:www.domain.com/article/the-bp-oil-spill-one-year-later/19918396/20110420/
要
http:www.domain.com/article/the-bp-oil-spill-one-year-later/19918396/2011/04/20/
我原来的重写是:
RewriteRule ^article/([^/]+)/([0-999999999]+)/([0-99999999]+)/?$ /index.php?a=show-post&slug=$1&articleid=$2&date=$3 [QSA,L]
我试图将此消除为一种类似的模式:
domain/2011/04/20/article-name-here/
感谢你的帮助。
谢谢, →
答案 0 :(得分:1)
你是否喜欢这样的事情:
URL Example: blah/20080101/
RewriteRule ^blah/([0-9]{0,4})([0-9]{0,2})([0-9]{0,2})/$ /blah/$1/$2/$3/
输出:
/blah/2008/01/01/
答案 1 :(得分:0)
当前/旧:/ article / the-bp-oil-spill-one-year-later / 19918396/20110420 /
RewriteRule ^article/([^/]+)/([0-999999999]+)/([0-99999999]+)/?$ /index.php?a=show-post&slug=$1&articleid=$2&date=$3 [QSA,L]
Desired / New:2011/04/20 / article-name-here /
RewriteRule ^article/([^/]+)/([^/]+)/([0-9]{0,4})([0-9]{0,2})([0-9]{0,2})/?$ /$3/$4/$5/$1 [R=301,QSA,L]
这将允许将您当前/旧样式网址的现有链接重定向(永久)到您的新样式网址。这假设您的php应用程序不需要也传递了articleid - 请注意,articleid不在您的新/所需URL中。