Ultima attività 8 months ago

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

timmy ha revisionato questo gist 8 months ago. Vai alla revisione

Nessuna modifica

timmy ha revisionato questo gist 8 months ago. Vai alla revisione

6 files changed, 63 insertions

express_redirect.js(file creato)

@@ -0,0 +1,10 @@
1 + const express = require('express');
2 + const app = express();
3 +
4 + app.get('/oldpage', (req, res) => {
5 + res.redirect('https://www.newpage.com');
6 + });
7 +
8 + app.listen(3000, () => {
9 + console.log('Server is running on port 3000');
10 + });

flask_redirect.py(file creato)

@@ -0,0 +1,10 @@
1 + from flask import Flask, redirect
2 +
3 + app = Flask(__name__)
4 +
5 + @app.route('/oldpage')
6 + def old_page():
7 + return redirect("https://www.newpage.com")
8 +
9 + if __name__ == '__main__':
10 + app.run(port=5000)

php_redirect.php(file creato)

@@ -0,0 +1,4 @@
1 + <?php
2 + header("Location: https://www.newpage.com");
3 + exit();
4 + ?>

redirect_page.html(file creato)

@@ -0,0 +1,11 @@
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(file creato)

@@ -0,0 +1,13 @@
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(file creato)

@@ -0,0 +1,15 @@
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>
Più nuovi Più vecchi