Остання активність 8 months ago

從 Express、Flask 到 PHP、HTML 與 JavaScript,轉址技巧一次收下!快轉跳轉不求人 ✨

Версія b9443e0ca6eaacc998f42c3f814ade27d0199231

express_redirect.js Неформатований
1const express = require('express');
2const app = express();
3
4app.get('/oldpage', (req, res) => {
5 res.redirect('https://www.newpage.com');
6});
7
8app.listen(3000, () => {
9 console.log('Server is running on port 3000');
10});
flask_redirect.py Неформатований
1from flask import Flask, redirect
2
3app = Flask(__name__)
4
5@app.route('/oldpage')
6def old_page():
7 return redirect("https://www.newpage.com")
8
9if __name__ == '__main__':
10 app.run(port=5000)
php_redirect.php Неформатований
1<?php
2header("Location: https://www.newpage.com");
3exit();
4?>
redirect_page.html Неформатований
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8">
5 <meta http-equiv="refresh" content="5; url=https://www.newpage.com">
6 <title>Redirecting...</title>
7</head>
8<body>
9 <p>If you are not redirected in 5 seconds, <a href="https://www.newpage.com">click here</a>.</p>
10</body>
11</html>
redirect_script.html Неформатований
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8">
5 <title>Redirecting...</title>
6 <script type="text/javascript">
7 window.location.href = "https://www.newpage.com";
8 </script>
9</head>
10<body>
11 <p>Redirecting...</p>
12</body>
13</html>
redirect_with_timeout.html Неформатований
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8">
5 <title>Redirecting...</title>
6 <script type="text/javascript">
7 setTimeout(function() {
8 window.location.href = "https://www.newpage.com";
9 }, 5000); // 5 seconds
10 </script>
11</head>
12<body>
13 <p>If you are not redirected in 5 seconds, <a href="https://www.newpage.com">click here</a>.</p>
14</body>
15</html>