htaccess将文件夹重定向到另一个文件夹 [英] htaccess redirect folder to another folder

查看:416
本文介绍了htaccess将文件夹重定向到另一个文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何重定向 http://mysite.com/folder/category-old/转到 http://mysite.com/folder/category-new/

注意:
1.所有文件夹中都存在相同的类别。
2.文件夹是变量,可以是 folder2或 folder3
3.最终文件夹将始终为/ category-new /

NOTE: 1. the same 'category' exists in all folders. 2. "folder" is variable and could be "folder2" or "folder3" 3. the final folder will always be /category-new/

推荐答案

使用 mod_rewrite 。在根目录下的.htaccess中放置以下内容:

Use mod_rewrite. Place something like this in .htaccess in the root directory:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/category-old/(.*)$ $1/category-new/$2 [R,L] 

请参见 http://httpd.apache.org/docs/ 2.2 / mod / mod_rewrite.html 了解更多信息。

这篇关于htaccess将文件夹重定向到另一个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆