当前位置: 动力学知识库 > 问答 > 编程问答 >

php - .htaccess redirect href (from facebook or google) to main page

问题描述:

I'm trying to make a .htaccess file to help me with:

-if someone access my website secondary pages (adau.ga/xxx.php) or images(adau.ga/images/xxx.jpg) from anoather website (facebook, google, etc.) to redirect them to main page www.adau.ga/index.php.

Can this be done?

I made this this code:

rewriteengine on

#RewriteRule ^images/(.*)$ /$1 [R=301,L]

ErrorDocument 404 http://www.adau.ga/#portfolio

And it seems that if it works for the links on facebook, but for google they don't work.

Help, please :)

网友答案:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://adau.ga/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://adau.ga$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.adau.ga/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.adau.ga$      [NC]
RewriteRule .*\.(txt|html|htm|php|swf)$ http://adau.ga [R,NC]
分享给朋友:
您可能感兴趣的文章:
随机阅读: