LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how can i rewrite (https://www.linuxquestions.org/questions/linux-general-1/how-can-i-rewrite-307652/)

csstudy 03-30-2005 01:18 AM

how can i rewrite
 
i want to url rewrite from http://123.www.abc.com/a.html (to )http://www.abc.com/document/123/a.html, the "abc" is my host.

how can I rewrite

druuna 03-30-2005 01:35 AM

Hi,

This will probably do what you want:

sed 's%http://\(123\).http://www.abc.com/a.html%http://www...ent/\1/a.html%'

Sed is not bound to the / seperator, it can be any charachter as long as they are the same. Because your string contains /, I decide to use % as sed seperator.

The \(123\) in the searchstring and the \1 in the replacestring are 'special' and called backreference. The \1 is replaced with the content between \( and \) in the searchstring (123 in this case).

Hope this helps.


All times are GMT -5. The time now is 02:20 PM.