简体   繁体   English

简单的PHP标头重定向在添加域中不起作用

[英]Simple php header redirect not working in add on domain

I am using a very simple header redirect: 我正在使用一个非常简单的标头重定向:

<?php header('Location: http://www.example.com'); ?>

I am using this in an add-on domain so the directory structure looks like this: 我在附加域中使用它,因此目录结构如下所示:

/home/username/public_html/addondomain.com/goto/directory/redirect.php

It doesn't work when I have it in this directory, but it does work in a different directory in my main account. 当我将其放在此目录中时,它不起作用,但在我的主帐户中的其他目录中,它却起作用。 For example: 例如:

/home/username/public_html/recommends/redirect.php

It would seem to be a problem with the directory permissions, but everything seems to be fine. 目录权限似乎有问题,但一切似乎都很好。 Is this possibly a problem with the add on domain? 这可能是附加域的问题吗?

This is probably something really simple, but I just can't figure it out. 这可能真的很简单,但是我无法弄清楚。 Any help would be appreciated. 任何帮助,将不胜感激。

Thanks Barry 谢谢巴里

I managed to fix this myself using .htaccess. 我设法使用.htaccess修复了此问题。 Thanks everyone for your comments. 感谢大家的意见。

Here is a sample of the code I used: 这是我使用的代码示例:

<IfModule mod_rewrite.c>    
RewriteEngine on
RewriteRule ^goto/directory/([/_0-9a-zA-Z-]+)$ link.php?id=directory&id2=$1
</IfModule>

This now calls a php file called link.php which looks up the user information from the MySQL database to complete the link. 现在,这将调用一个名为link.php的php文件,该文件将从MySQL数据库中查找用户信息以完成链接。 The link.php file redirects to the newly created link using the header() function. link.php文件使用header()函数重定向到新创建的链接。 This way I can have unlimited affiliates creating custom links. 这样,我可以让无限的会员创建自定义链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM