[英].htaccess redirect only last portion
I've moved a WordPress website from an old version to a new version. 我已经将WordPress网站从旧版本移到了新版本。 Blog URLs are broken now.
博客网址现已损坏。 How to create a redirect that will take only the last portion of the url and append it to the domain.
如何创建重定向,该重定向将仅使用url的最后一部分并将其附加到域中。 Here is an example:
这是一个例子:
http://www.dummydomain/3454/uncategorized/post-name-here ==> http://www.dummydomain/post-name-here http://www.dummydomain/3454/uncategorized/post-name-here ==> http://www.dummydomain/post-name-here
the 3454 and the uncategorized are different between posts so I can't hardcode that. 3454和未分类的文章之间是不同的,所以我不能硬编码。
I searched allot but couldn't find anything related to this. 我搜索了分配,但找不到与此相关的任何内容。 Any guidance or help would be appreciated.
任何指导或帮助,将不胜感激。
You can use this code in your DOCUMENT_ROOT/.htaccess
file: 您可以在
DOCUMENT_ROOT/.htaccess
文件中使用以下代码:
RewriteEngine On
RewriteRule (?:^|/)([^/]+)/?$ /$1 [L,NE,R=302]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.