Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove part of a URL

How can I remove main/ in http://domain/main/about

so the URL will be like this http://domain/about

Thanks

like image 515
Ralph Avatar asked Apr 27 '11 06:04

Ralph


People also ask

How do you remove something from a URL?

To request removal of a directory or site, click on the site in question, then go to Site configuration > Crawler access > Remove URL. If you enter the root of your site as the URL you want to remove, you'll be asked to confirm that you want to remove the entire site.

How do you remove part of a URL in Python?

An option using regex /[^/]+$ and replace with an empty string. This matches the last foward slash until the end of the string.

How do you get rid of the last part of a URL in Python?

Give the last element to the strip method, it will return the string by removing the last character.


1 Answers

Well, in the absence of any further details, you could try something like this:

RewriteRule (.*)/main/(.*) $1/$2

But this is a VERY broad rule - you'd probably want to tune it more tightly than that. Try turning the RewriteLogLevel to 9 and watching the rules as they get processed so you can get a better idea of what is being matched.

like image 195
TML Avatar answered Sep 22 '22 13:09

TML