如何重定向URL上级目录与URL重写 [英] How to redirect url to parent directory with url rewriting

查看:253
本文介绍了如何重定向URL上级目录与URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从一个子目录的父目录进行重定向。

I need to make redirections from a sub-directory to the parent directory.

在换句话说,我要重定向任何匹配

In other words I have to redirect anything matching

http://exemple.com/portfolio/product1

http://exemple.com/product1

有没有办法做到这一点与URL重写?

Is there any way to do that with URL REWRITE ?

感谢

推荐答案

的httpd.conf 启用了mod_rewrite和.htaccess,然后把这个code在< $ C C>的.htaccess $ DOCUMENT_ROOT 目录下:

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^portfolio/(.*)$ /$1 [L,R=301,NC]

这篇关于如何重定向URL上级目录与URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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