I'm trying to rewrite the following URL but can't get it to work (I've read all the htaccess basics at apache.org). http://www.example.com/util/doc.jsp?n=document-num_137298138853890.pdf I'd be most grateful if anyone with more experience could point out where I'm going wrong. My htaccess code is: RewriteBase / RewriteCond %{QUERY_STRING} ^n=document-num_137298138853890\.pdf$ RewriteRule ^util/doc.jsp$ http://www.example.com [R=permanent,L] Code (markup):
Try this RewriteCond %{QUERY_STRING} ^n=document-num_137298138853890\.pdf$ RewriteRule ^util/doc.jsp$ / [R=permanent,L] Code (markup):
Try below syntax : Redirect old file path to new file path Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html