Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove part of URl with .htaccess?

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

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

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

http://www.example.net/mission

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.

like image 724
Salman Aslam Avatar asked Oct 10 '11 08:10

Salman Aslam


1 Answers

You would need the rewrite module of Apache: mod_rewrite.

Then do something like this:

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

Here is the official documentation of mod_rewrite: click

like image 118
janoliver Avatar answered Oct 08 '22 20:10

janoliver