如何使用的.htaccess删除URL的一部分? [英] How to remove part of URl with .htaccess?

查看:436
本文介绍了如何使用的.htaccess删除URL的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我有我的网站上20+的网址在这甲

Currently i have 20+ URLs on my site in this formate

http://www.example.net/content/index/mission

我想从所有的URL删除/内容/指数,所以他们应该是这个样子。

I want to remove /content/index from all URLs, so they should look something like this

http://www.example.net/mission

在换句话说,我将永远从URL中删除/内容/索引。 我敢肯定,这确实直线前进,但我不是很有经验与Apache。

In other words I would to always remove /content/index from the url. I'm sure it's really straight forward, but I'm not very experienced with Apache.

推荐答案

您将需要Apache的重写模块:的mod_rewrite

You would need the rewrite module of Apache: mod_rewrite.

然后做这样的事情:

RewriteEngine on 
RewriteRule ^content/index/(.*)$ $1

下面是mod_rewrite的正式文件:点击

Here is the official documentation of mod_rewrite: click

这篇关于如何使用的.htaccess删除URL的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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