Son aktivite 8 months ago

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

Revizyon f558c227b784c04363994f8c69ea94ec351d47c1

express_redirect.js Ham
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 Ham
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 Ham
1<?php
2header("Location: https://www.newpage.com");
3exit();
4?>
redirect_page.html Ham
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 Ham
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 Ham
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>