It's actually very simple, try this:
Redirect all requests from: parent/special/(.*)
to: parent/$1
If you're using Apache, the RewriteRule would look like this:
RewriteRule parent/special/(.*) parent/$1 [R=301]
Question
I am trying to create a rule that redirects /parent/special/{anything} to /parent/{anything}. In other words to remove the "special" from the URL if it is there after "parent". This is for a .NET application, more specifically for http://urlrewriter.net. Can someone help with this?
Solution 2
It's actually very simple, try this:
Redirect all requests from: parent/special/(.*)
to: parent/$1
If you're using Apache, the RewriteRule would look like this:
RewriteRule parent/special/(.*) parent/$1 [R=301]
OTHER TIPS
If you're using a PCRE compliant language, you could use this:
(\/\w+\/)(?:special\/)?(.*$)
And replace with: $1$2
.
Example: http://regex101.com/r/uM8rA7
If you specifically want /parent
, just replace \w+
with parent
.
Edited to allow for anything after /special
.
The following regex:
(\/\w+\/)special\/
Would capture the /parent/
path only if it's followed by special
.
you can try this:
sed -i 's/parent\/special/parent/g' file.txt