• About
  • Policy
  • Contact

Phan Anh Buổi Sáng

  • Home
  • Kiến thức IT
    • PSD
    • Blogger
  • Translate
Google
Custom Search
Trang chủ » TUTORIALS » Hướng dẫn tạo trang redirect theo tình huống

Hướng dẫn tạo trang redirect theo tình huống

Unknown Labels: TUTORIALS Leave A Comment 06:52
Download:
http://www.mediafire.com/?v4c8bjuacbp272t

1. Reditect theo referer: Tức là ta set nếu request từ 1 domain cho trước thì redirect đến trang A, tất cả request còn lại thì redirect tới trang B dựa vào script check referer của PHP. Không biết bạn hình dung ra chưa nhưng xem đoạn script dưới đây thì bạn sẽ nhận ra thôi

Code:
<?php
$referer=$_SERVER["HTTP_REFERER"];
$referer=parse_url($referer);
$referer=$referer['host'];
$referer=str_replace("www.","",$referer);

if ($referer=="hacker4a.net") {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.vncracking.com/web-tools/" ); }
else {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.vncracking.com/" ); }
?>
Với đoạn script trên thì mọi request từ domain hacker4a.net sẽ được chuyển đến http://www.vncracking.com/web-tools/ và những request bất kỳ còn lại sẽ được chuyển đến domain gốc http://www.vncracking.com

Redirect theo địa chỉ IP cho trước:
Trích dẫn:
<?php
$ip=$_SERVER["REMOTE_ADDR"];

if ($ip=="210.245.120.84"){
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://yahoo.com/" ); }
else {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.vncracking.com/" ); }
?> 
 Khi đó máy có IP là 210.245.120.84 sẽ được redirect sang http://www.yahoo.com/ còn tất cả IP còn lại sẽ được chuyển sang http://www.vncracking.com/

Tương tự với 2 địa chỉ IP cho trước:

Code:

<?php
$ip=$_SERVER["REMOTE_ADDR"];

if ($ip=="210.245.120.84") {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.yahoo.com/" ); }
elseif ($ip=="230.162.5.184") {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.google.com/" ); }
else {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.vncracking.com/" ); }
?>
- IP mới thêm vào sẽ được chuyển sang http://www.google.com/
- Và nhiều hơn 2 IP thì ta cũng làm tương tự với elseif.


Lấy một trường hợp khác. Ta có 2 địa chỉ IP là: 210.245.120.84 và 230.162.5.18 khi truy cập vào trang web ta muốn máy có IP là 210.245.120.84 sẽ bị chuyển sang yahoo.com, máy có IP là 230.162.5.18 sẽ bị pasword protect chặn lại còn tất cả máy khác thì được chuyển sang vncracking.com. Ta làm như sau:

Code:

<?php
$ip=$_SERVER["REMOTE_ADDR"];

if ($ip=="210.245.120.84") {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.yahoo.com/" ); }
elseif ($ip=="230.162.5.18") {
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="VNP Community"'); }
else {
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.vncracking.com/" ); }
?>
 Mốt số mẫu khác :

- Lưu ý: Ở các mẫu bên dưới các bạn thay http://www.new-url.com bằng url mà các bạn muốn redirect tới.

ColdFusion Redirect:

<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.new-url.com">
PHP Redirect:

Code:

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>
 ASP Redirect:

Code:

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com/");
%>
ASP .NET Redirect:

Code:

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}
</script>
 JSP (Java) Redirect:

Code:

<%
response.setStatus(301);
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
%>
CGI PERL Redirect:

Code:

$q = new CGI;
print $q->redirect("http://www.new-url.com/");
 Ruby on Rails Redirect:

Code:

def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to "http://www.new-url.com/"
end
Htaccess Redirect:

Code:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
 HTML Metatag Redirect: (Not 301 Redirect)

Code:

<meta http-equiv="refresh" content="x; URL=http://www.new-url.com">
- x là số thời gian bạn muốn trang web chuẩn bị tự động di chuyển tính bằng giây (sec).

Java-Script Redirect: (Not 301 Redirect)

Code:
<script>window.location.replace('http://www.new-url.com');</script>

Bài viết liên quan

← Bài đăng mới hơn Bài đăng cũ hơn → Trang chủ
Powered by Blogger.

Các Bình Luận Gần Đây

Bài đăng phổ biến

  • 10 tên tội phạm máy tính từng "làm khổ" cả thế giới (phần 1)
    Ngay từ những ngày đầu tiên khi những chiếc máy tính ra đời từ cách đây hơn 50 năm, một loại tội phạm mới cũng theo đó mà xuất hiện: tội p...
  • Ảnh bìa chế Phía sau một cô gái - Soobin Hoàng Sơn - Zoy Thủ Thuật #Zoy
    Đôi lúc em tránh ánh mắt của anh. vì dường như lúc nào em cũng hiểu thấu lòng anh Demo Cover Download PSD loading...
  • [Warning] Freecode.vn
    Exploit: SQL Injection Đánh giá: Nghiêm trọng. Khai thác: Query lấy thông tin User. Tình trạng: (Đang liên hệ Quản trị viên) .
  • 403 Forbidden and cant read /etc/named.conf Error Bypass
    This Tut has been submitted by Sen Haxor Now days most of the 2012 Linux Kernel server show this error when you try to symlink the serve...
  • .htaccess security
    Để vào các foder file .htacces phòng tránh up shell: <Files ~ “^.*\.(php|cgi|pl|php3|php4|php5|php6|phtml|shtml) ”>...
  • TRAO ĐỔI TEXTLINK CHO BLOG
    LINK LIÊN KẾT ( Copy link   này vào trang  Home  của website bạn ) <a href=' https://letientruong.blogspot.com/ ' title=' Lê...
  • Share CMND Người Dân Tộc
    Demo :  http://link4ad.net/ssTSc3wk Download :  http://link4ad.net/NecR8DBe Độc quyền share tại  Minh Haku IT
  • [PSD] Ảnh Bìa Alan Walker - Zoy Thủ Thuật Blog
    Ảnh Bìa Alan Walker - Zoy Thủ Thuật Blog
  • Backdoor Scanner
    Code: <?php /* ################################################################################# # [+] File Name : Devilzc0de Backdoor Sc...
  • Share kho tài liệu mạng hữu ích
    Tài liệu share gồm 1/ Bộ DVD CCNA được tập hợp của 3 trung tâm VNPRO, Nhất Nghệ và Sao Bắc Đẩu. Link download: http://www.fshare.vn/file/TN4...

Pageviews from the past week

Chuyên mục

Bài đăng phổ biến

  • 10 tên tội phạm máy tính từng "làm khổ" cả thế giới (phần 1)
    Ngay từ những ngày đầu tiên khi những chiếc máy tính ra đời từ cách đây hơn 50 năm, một loại tội phạm mới cũng theo đó mà xuất hiện: tội p...
  • Ảnh bìa chế Phía sau một cô gái - Soobin Hoàng Sơn - Zoy Thủ Thuật #Zoy
    Ảnh bìa chế Phía sau một cô gái - Soobin Hoàng Sơn - Zoy Thủ Thuật #Zoy
    Đôi lúc em tránh ánh mắt của anh. vì dường như lúc nào em cũng hiểu thấu lòng anh Demo Cover Download PSD loading...
  • [Warning] Freecode.vn
    [Warning] Freecode.vn
    Exploit: SQL Injection Đánh giá: Nghiêm trọng. Khai thác: Query lấy thông tin User. Tình trạng: (Đang liên hệ Quản trị viên) .
  • 403 Forbidden and cant read /etc/named.conf Error Bypass
    This Tut has been submitted by Sen Haxor Now days most of the 2012 Linux Kernel server show this error when you try to symlink the serve...
  • .htaccess security
    Để vào các foder file .htacces phòng tránh up shell: <Files ~ “^.*\.(php|cgi|pl|php3|php4|php5|php6|phtml|shtml) ”>...
  • TRAO ĐỔI TEXTLINK CHO BLOG
    TRAO ĐỔI TEXTLINK CHO BLOG
    LINK LIÊN KẾT ( Copy link   này vào trang  Home  của website bạn ) <a href=' https://letientruong.blogspot.com/ ' title=' Lê...
  • Share CMND Người Dân Tộc
    Share CMND Người Dân Tộc
    Demo :  http://link4ad.net/ssTSc3wk Download :  http://link4ad.net/NecR8DBe Độc quyền share tại  Minh Haku IT
  • [PSD] Ảnh Bìa Alan Walker - Zoy Thủ Thuật Blog
    [PSD] Ảnh Bìa Alan Walker - Zoy Thủ Thuật Blog
    Ảnh Bìa Alan Walker - Zoy Thủ Thuật Blog
  • Backdoor Scanner
    Code: <?php /* ################################################################################# # [+] File Name : Devilzc0de Backdoor Sc...
  • Share kho tài liệu mạng hữu ích
    Tài liệu share gồm 1/ Bộ DVD CCNA được tập hợp của 3 trung tâm VNPRO, Nhất Nghệ và Sao Bắc Đẩu. Link download: http://www.fshare.vn/file/TN4...
Google
Custom Search
Support: Facebook | Twitter | Google+ | Giới thiệu
Copyright © 2015 • Phan Anh Buổi Sáng • All Right Reserved. Template by Template Việt