Pages

Wednesday, 8 May 2013

how redirect by .htaccess with a link of space %20

Redirect by .htaccess is easy for a server.
If you want to redirect a link then put the .htaccess file in root folder of the server.
Then put the following of code in .htaccess file.

Redirect 301 old_link.html  new_link.html

the above is normal rule. but if you have space in the old link (not _ ) then it makes problem.

then add the following code after RewriteEngine On

RewriteRule ^/?tag/(.*)\ (.*)$ /tag/$1-$2   [L,R=301]

then put the redirect condition suppose:

Redirect 301 '/codebooks/Malawi Geocoded Aid Codebook.pdf' http://aiddata.org/weceem_uploads/_ROOT/File/geocoding/UCDP_AidData_Codebook_Published.pdf

the Malawi Geocoded Aid Codebook.pdf is in single cote and this link has %20 or space

it was :  /Malawi%20Geocoded%20Aid%20Codebook.pdf 


i have become success by following above rule.





No comments:

Post a Comment