English 中文(简体)
B. 间接法问题
原标题:Issues with redirect code

当人们访问我的主页(指数.php)时,我想要将他们改用索引。

To do this, I added a simple html code in the head:

<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.domain.com/index.php?page_id=2">

The problem is that the destination and all other pages of my site runs that code it goes on a loop. I am using Wordpress. Is there any solution to direct them to index.php?page_id=2 upon visiting index.php without it going on a loop?

任何援助都将受到高度赞赏。

最佳回答

To avoid infinite loops, just check if the $_GET variable is empty. If so, do a redirect:

if (empty($_GET))
{
    header( Location: index.php?page_id=2 );
}
问题回答

从根本上说,你需要确保在指数中不插入“梅塔复读”。 php在其询问说明中有论点(如页)。

如果你刚刚在PHP中这样做,你将写一句话,用“GET”表检查询问的内容,即“GET[网页_id”]。

简言之(我不太了解这一点),你可能找到一种完全不同的解决办法,就是你想要的。 例如,一个 met子实际上被认为低于所谓的吉大港定居地保有权改头——具有同样效果的头盔。

在公共卫生和社会福利部中:

http://php.net/manual/en/Function. http-redirect.php

我注意到,文字压缩文件提到了间接公用事业;我试图提供这些链接,但StackOverflow阻止我再把他包括在内。 在其文件中寻找“直接”可能是有益的。

In general, I would expect to see an if statement that decides whether or not to issue a redirect, either using PHP s mechanism, or Wordpress .

我希望这是有益的。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签