There is a handy tool for in-depth settings in yout linux, install dconf with:
sudo apt-get install dconf-tools
Open the tool. Now check some interessting paths:
# settings for nautilus org –> gnome –> nautilus –> preferences
Simply redirecting a domain, ending with source to target/index.html
RewriteRule ^source/?$ http://www.test.de/target/index.html [L]
Redirecting can also be done with the Redirect Command
Redirect 301 /source /target/some-folder
Redirecting a complete folder structure can be done like this:
RedirectMatch 301 ^/source/(.*)$ http://mydomain.de/target/$1
Redirect a request for a specific file to a folder (http://www.test/upload/file.pdf -> http://www.test.de/downloads/)
The flag R stands for redirect, L stands for Last (the rule will be executed immediately, without chaining another rule)
RewriteEngine On RewriteRule ^/?file\.pdf$ http://www.test.de/downloads/ [R, L]
In reality you have quite often perform a certain command on several files. First i detect all files I’m looking for and store them in a filelist.
find . -name "myFilename" > filelist.txt
Second i run through this file, line by line and perform my command on all filename I’ve received one step before.
while read -r LINE; do echo "$LINE"; done < filelist.txt
You need to replace in several files. You can do it with sed. Be aware about masking special chars. In the example below the string „my\folder“ is replaced with „your\folder“.
Replacing with sed works like this: sed -i s#old#new#g
The delimiter (in this case the #) can be changed. The first sign after the s acts as delimiter.
while read -r LINE; do sed -i s#\"my\/folder\",\"your\/folder\"#g "$LINE"; done < filenames.txt