简体   繁体   English

.htaccess仅从/ category / category-name / id >> / id重定向

[英].htaccess redirect from /category/category-name/id >> /id only

I have problem and I'm already crazy about it. 我有问题,我已经对此感到疯狂。

I am learning to code by myself and start little web project based on wordpress. 我正在学习自己编写代码,并开始基于wordpress的小型Web项目。

First of all, i have this problem my main problem 首先,我有这个问题是我的主要问题

And I am having idea, that I can use RewriteRule in .htaccess to automatically redirect from mypage.com/category/category-name/post-id to only mypage.com/post-id 我有一个主意,就是可以在.htaccess中使用RewriteRule自动将其从mypage.com/category/category-name/post-id重定向到mypage.com/post-id

I tried RewriteRule ^category/([^/]*)/([^/]*)$ /$1 [L] but not working. 我尝试了RewriteRule ^category/([^/]*)/([^/]*)$ /$1 [L]但没有用。

Can anyone please help me? 谁能帮帮我吗?

Thank you very much 非常感谢你

Assuming your id is an integer - 假设您的ID是整数-

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/folder1/([0-9]+)$ http://example.com/$1 [R=301,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM