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

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

问题描述

目前我在我的网站上有 20 多个这种格式的网址

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

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

我想从所有 URL 中删除/content/index,所以它们应该看起来像这样

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

http://www.example.net/mission

换句话说,我总是会从 url 中删除/content/index.我敢肯定它真的很简单,但我对 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天全站免登陆