Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
September 05, 2026 - @440.61
Activity rating: Four Stars Posts & Arts: 71/1k.beats Random | Recent Posts | Guild Recents
News: It's only life! :dog: Guild Events: 10: window

+  MelonLand Forum
|-+  Life & The Web
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  Making an autoredirect point to the same page on diff domain


« previous next »
Pages: [1] Print Embed
Author Topic: Making an autoredirect point to the same page on diff domain  (Read 1335 times)
candycanearter07
Hero Member ⚓︎
*****
View Profile WWWArt


i like slimes
⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!it's tbhchansey!Goomy, I Choose You!uh oh! a pigeon got in!Artsy Candy Cane
« on: May 11, 2025 @727.53 » Embed

Hi,

So I've been considering moving off of a neocities url and buying my own domain. The problem is that there's already a ton of links out there that point to my page.. Redirecting would obviously be the best thing, using the 404 page, but I am worried about like the path on the link being lost if i just linked directly to the domain. Is there any way to make the autoredirect point to the same path in the new domain?

ie
foo.neocities.org/about
-> example.org/about

Logged

new to oldnet be nice
https://status.cafe/users/candycanearter/badge.png https://abslimeware.neocities.org/assets/images/blinkers/penguins.gif

https://abslimeware.neocities.org/assets/images/blinkers/slimebounce.gif https://card.exophase.com/2/0/268504.png?1727352149

https://i.imgur.com/S1cx8ZZ.pnghttps://i.imgur.com/7ntZZGM.pnghttps://i.imgur.com/xKIpW2A.pnghttps://i.imgur.com/YMPbu9R.png

Artifact Swap: buzzystickerSootBlob Creaturecards all the way downHuman Connection
Melooon
Hero Member ⚓︎
*****
View Profile WWWArt


So many stars!
⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: melon
iMood: Melonking
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
Top HatBug!You're a Star!Flinstone VitaminI got robbed by Dan Q on Melonland!Always working hard!
« Reply #1 on: May 11, 2025 @732.23 » Embed

If you're planning to get Neocities supporter and add your custom domain there then you don't need to worry about this issue, Neocities will automatically redirect any old links correctly  :wizard:

However if you're switching host entirely then your best bet is to replace every page on neocities with a custom redirect page.

This is an example redirect page:
Code
<html>
    <head>
        <title>My Old page</title>
        <meta http-equiv="refresh" content="4; URL=https://mynew.url/newpage" />
        <meta property="article:modified_time" content="2025-04-11T21:34:00-0700" />
        <style>
            body {
                padding: 30px 30%;
                text-align: center;
                font-size: 2em;
            }
        </style>
    </head>
    <body>
        <p>I have moved stand by to be redirected!!</p>
    </body>
</html>

The key thing is the two meta tags in the head, the first tells the browser to refresh the tab to a new url (the content=4 value is the length of the delay in seconds before redirecting, you can make it 0 for instant redirects), and the second tells the browser to clear its cache so that the refresh 100% happens (just set it to whatever date you setup your new site) - you can also just add this meta data to your old pages head ^^

Logged


everything lost will be recovered, when you drift into the arms of the undiscovered

Artifact Swap: Have a chillpillblack n orange yappin kittayRed TulipLurbyxDPlankGo dig, girl!
candycanearter07
Hero Member ⚓︎
*****
View Profile WWWArt


i like slimes
⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: candycanearter
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
Visited on Melon's 10th Anniversary!it's tbhchansey!Goomy, I Choose You!uh oh! a pigeon got in!Artsy Candy Cane
« Reply #2 on: May 11, 2025 @769.88 » Embed

So I'd have to manually replace all my pages?

Logged

new to oldnet be nice
https://status.cafe/users/candycanearter/badge.png https://abslimeware.neocities.org/assets/images/blinkers/penguins.gif

https://abslimeware.neocities.org/assets/images/blinkers/slimebounce.gif https://card.exophase.com/2/0/268504.png?1727352149

https://i.imgur.com/S1cx8ZZ.pnghttps://i.imgur.com/7ntZZGM.pnghttps://i.imgur.com/xKIpW2A.pnghttps://i.imgur.com/YMPbu9R.png

Artifact Swap: buzzystickerSootBlob Creaturecards all the way downHuman Connection
nobo
Full Member ⚓︎
***
View Profile WWW


drainnnn
⛺︎ My Room
StatusCafe: nobo
iMood: nobo
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
First 1000 Members!Joined 2023!
« Reply #3 on: May 11, 2025 @847.52 » Embed

You could do it with a script, although that might be advanced. It could be worth it to learn to write the script if there is enough pages, but if there's few enough pages, it might be better to do manually.

Logged

https://board.goeshard.org/static/images/button-88-31.3b39bc79220a.png
crazyroostereye
Full Member ⚓︎
***
View Profile WWW


I am most defiantly a Human
⛺︎ My Room
iMood: Crazyroostereye
RSS: RSS

Guild Memberships:
Artifacts:
Joined 2024!
« Reply #4 on: May 13, 2025 @662.91 » Embed

I wrote a little Python script that adds the Necessary meta tags to each Page that @Melooon mentioned in his previous Post.
 :pc:
Code
import sys, os, shutil
from bs4 import BeautifulSoup

folder = sys.argv[1]
domain = sys.argv[2]
outfolder = sys.argv[3]

for (dirpath, dirnames, filenames) in os.walk(folder):
    for i in filenames:
        new_path = dirpath.replace(folder, outfolder)
        if i.split(".")[-1] != "html":
            print(f"Copying {dirpath}/{i} to {new_path}/{i}")
            os.makedirs(f"{new_path}", exist_ok=True)
            shutil.copyfile(f"{dirpath}/{i}", f"{new_path}/{i}")
            continue
        domain_path = f"{domain}{dirpath.replace(folder, "")}/{i}"
        print(f"Processing {domain_path}")
        with open(dirpath+"/"+i, "r") as f:
            html = f.read()
        soup = BeautifulSoup(html, "html.parser")
        meta1 = soup.new_tag("meta")
        meta1["http-equiv"] = "refresh"
        meta1["content"] = f"4; URL={domain_path}"
        soup.find("head").append(meta1)

        meta2 = soup.new_tag("meta")
        meta2["property"] = "article:modified_time"
        meta2["content"] = "2025-04-11T21:34:00-0700"
        soup.find("head").append(meta2)

        os.makedirs(f"{new_path}", exist_ok=True)
        with open(f"{new_path}/{i}", "w") as f:
            f.write(str(soup))
So you have to have python3 and the bs4 module for this to work. Also I only tested it on a Linux machine. It should work on Mac but I am not sure if it works on Windows.

main.py /path/to/old/website/root https://new.domain.net /folder/to/output/fixed/site

If you need further help or the script dosen't work you are welcome to message me.  :smile:

EDIT 17:02:11 : I updated the script to copy non html files also over to the outfolder

« Last Edit: May 13, 2025 @668.69 by crazyroostereye » Logged

https://crazyroostereye.de/stuff/Crazy31.gifhttps://ayoreis.com/static/Arch.pnghttps://crazyroostereye.de/stuff/Zen31.png
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
@000 MelonLand Editor Recent Edits Tenement Arcade Want to Login or Join ? Forum Art Hub Chat Webring Web Guides Graphics Catalogue Wiki Newsletters Image Stream
Melon's Sites TamaNotchi Textures PixelSea GifyPet MoMG Ozwomp Online Loom Videos Leaky Webring Melonking
Tools Melon Software ArtHub Embed Maker ML Passports
Outlinks Frutiger Aero Forum Onio Club m15o's Web Services 32Bit Cafe iMood Webrings Internet Phone Book HTML Energy Declarations Hackers & Designers
Zap!
Minecraft: Online
Join: craft.melonking.net