开发者

Redirecting PDF links from another domain using htaccess

开发者 https://www.devze.com 2023-01-30 05:46 出处:网络
We have two domains, let\'s call them first.com and second.com We have a directory in second.com called reports, where all our PDFs are located, but we would like to these same PDFs accessible from f

We have two domains, let's call them first.com and second.com

We have a directory in second.com called reports, where all our PDFs are located, but we would like to these same PDFs accessible from first.com as well.

Can we redirect let's say first.com/reports/84839049.pdf to second.co开发者_运维问答m/reports/84839049.pdf using htaccess?


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^domain\.com
RewriteRule (.*) http://domain1.com/$1 [R=301, L]


Yes.
redirect /requested/url http://second.com/result/url

http://httpd.apache.org/docs/1.3/mod/mod_alias.html#redirect

You may want to consider using mod_rewrite though, unless you asked for an .htaccess configuration specifically because you have no access to the server configuration and mod_rewrite is disabled or not loaded.

http://httpd.apache.org/docs/current/mod/mod_rewrite.html http://webdesign.about.com/od/mod_rewrite/qt/site_redirects.htm

You'll need some grasp of regex for mod_rewrite, but it can make configuration of the redirects a lot faster than having to add a redirect for every file on your site(s).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号