Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
Autumn, 28 Oct 2026 - @833.76
Forum Activity: Four Stars Random | Recent Posts | Guild Recents
News: :sleep: These are fast times on the World Wide Web~ Guild Events: Halloween Watch-a-thon
Super News: ~~MelonLand's Halloween Profile Design Contest 2026~~
+  MelonLand Forum
|-+  Da Web Revival
| |-+  ✁ ∙ 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 1427 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: Spring, 11 May 2025 @728 » Toggle Font 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 Creature
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:
Caught by RubbereonYou're a Star!Flinstone VitaminWavy Shoulder-Length Hair with BangsBug!Top Hat
« Reply #1 on: Spring, 11 May 2025 @732 » Toggle Font 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 chillpillRed Tulip
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: Spring, 11 May 2025 @770 » Toggle Font 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 Creature
nobo
Sr. Member ⚓︎
****
View Profile WWWArt


drainnnn
⛺︎ My Room
StatusCafe: nobo
iMood: nobo
RSS: RSS
OS: LUNIX

Guild Memberships:
Artifacts:
First 1000 Members!Joined 2023!
« Reply #3 on: Spring, 11 May 2025 @848 » Toggle Font 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

Drain is about loss and gain; it could be good or bad.
You could be drained of energy or you could drain something to gain energy.
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: Spring, 13 May 2025 @663 » 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: Spring, 13 May 2025 @669 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 Melon
Land
Forum Art Hub Chat Webring Explore Random Recent Tenement Arcade Want to Login or Join ? Web Craft Guide Graphic Catalogue Wiki Help I'm Lost! Link Land Newsletters Image Stream Minecraft: Online
Zap!
Passport Sites tamaNOTchi Asatte Add your site?
Aero Archive Onio Cafe 32 Bit Cafe Status Cafe