Dynamic links - how to redirect if a page doesn't exist

Hi all! Hope you’re doing well.

Wondering if you kind folks are able to help me find the right solution here?
I have a usecase where I’d like to send people individual links like this:

I’d like this to redirect that page to the homepage, if possible keeping the path accessible (in order to display dynamic data on the homepage).

Failing this, changing it to a parameter would be acceptable too. ?u=their-name
This will be for hundreds of people, so manually creating a page for each is not feasible.

I’ve reviewed this post but unfortunately it seems the method no longer works.

I have also tried the inbuilt 301s in the settings. ChatGPT suggested I might be able to use variables but I didn’t have any luck with that.

Does anyone have any thoughts on how this could be achieved please? I’d be incredibly grateful for any help!

Thanks so much,

Hi @r111

That should be doable on Bubble. Some rough steps:

It should be the index page otherwise it will be mydomain.com/pagename/user-name
The page type should be USER
Slug as the current page user's name

How to send people to that page:
Action = Go to page → [your page] → Data to send = (do a search for user / current user)

That’s it! When sent to a page like this, it will show up as mydomin.com/user-name on the browser’s URL bar.

A different approach:
When user is created, also set the user’s slug as the name. If there’s a duplication it will automatically add a -1, -2 etc or you can use unique usernames as slugs.

Now set the page’s slug as the user’s slug. Then you can directly link to mydomain.com/[(do a search for user / current user)’ slug]

That will directly give you a clickable link - mydomain.com/userslug for external use.

Let me know if you have any questions or if this doesn’t work for you or if I’ve missed what you were looking for!

Hope that helped :slight_smile:

Parshva | Book a call

1 Like

Hi there @rohanjainneri - Thanks very much for your help with this. Excellent!
For extra context, these links will be delivered to people via email and they’ll use them to arrive to the bubble app.

I’ve just implemented this and have it working with the following structure:

Which is great, but I’m wondering if it is possible for this to work without ‘index’?
I guess failing that I could rename the index page to ‘u’ or something short.

Many thanks for your suggestions and help!

1 Like

Hi Rob,

That’s great, I’m glad I could help you!

There’s a small domain level hack you could try to get the mydomain.com/user-slug

Rename the page to u or something similiar, then open your domain’s .htaccess file and add this code:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/([^/]+)/?$
RewriteRule ^ /u/%1 [R=301,L]

So with this you could basically send people to mydomain.com/user-slug but the domain will redirect it to mydomain.com/u/user-slug


Parshva | Book a call

Hi @rohanjainneri - Amazing. That’s great thanks!

I’ll give that a go next week as I need access from my client. Appreciate the help - I have it working nicely for now with /u/username :slight_smile:

Have a great weekend,

1 Like

hi Rohan, how do you access the htaccess file? upon searching it seems this isn’t possible in bubble? thanks!

This cannot be set up in bubble, you need to check your domain name supplier

This topic was automatically closed after 70 days. New replies are no longer allowed.