开发者

redirect users to some file if the did not typed index.php in url php .htaccess

开发者 https://www.devze.com 2023-03-03 02:44 出处:网络
As titled I wants to show some information to users before accessing actual site and then redirect them to my sit开发者_JAVA技巧e.

As titled I wants to show some information to users before accessing actual site and then redirect them to my sit开发者_JAVA技巧e.

if they type my site url like mysite.com I want them to redirect them to mysite.com/info.php using .htaccess. and the info file show information for 3 seconds and then redirect them to my site mysite.com

How can I do this?


Create an htaccess containing: DirectoryIndex info.php

And add this on your info.php:

<meta http-equiv="refresh" content="3;url=http://example.com/index.php">

Be aware not to link to http://www.mysite.com in any of your websites 'homepage' links (or heading).. that would cause a user to see the info.php again. Refer to index.php/index.html instead.


.htaccess allows you to perform rewrite rules. Once you have redirected to a new page, you can't use .htaccess to do a redirection after the page has loaded.

One way would be to add JavaScript on mysite.com/info.php defined on the pages OnLoad() which would cause loading of mysite.com


You can redirect with php (if request is empty). But in info.php you can use code:

<meta http-equiv="refresh" content="3; url=http://www.mysite.com/?redirect">

After 3 seconds you can redirect to index page

In index page you must test query. If query is not empty don't redirect it again

OR you can use $_SERVER['HTTP_REFERER']

0

精彩评论

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

关注公众号