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

**URL:** <https://forum.bubble.io/t/dynamic-links-how-to-redirect-if-a-page-doesnt-exist/253294>\
**Category:** Need help\
**Created:** [March 24, 2023, 10:00am UTC](https://forum.bubble.io/t/dynamic-links-how-to-redirect-if-a-page-doesnt-exist/253294 "2023-03-24T10:00:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![r111](https://avatars.discourse-cdn.com/v4/letter/r/779978/32.png) [@r111](https://forum.bubble.io/u/r111)\
**Post date:** [March 24, 2023, 10:00am UTC](https://forum.bubble.io/t/dynamic-links-how-to-redirect-if-a-page-doesnt-exist/253294/1 "2023-03-24T10:00:30Z")

</div>

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:  
[mydomain.com/their-name](http://mydomain.com/their-name)

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](http://forum.bubble.io/t/pretty-urls-with-dynamic-links-mydomain-com-dynamiclink-solution-from-zeroqode/56311/65) 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,  
Rob

---

<div class="post-metadata">

**Author:** ![rohanjainneri](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/rohanjainneri/32/210872_2.png) [@rohanjainneri](https://forum.bubble.io/u/rohanjainneri)\
**Post date:** [March 24, 2023, 1:29pm UTC](https://forum.bubble.io/t/dynamic-links-how-to-redirect-if-a-page-doesnt-exist/253294/2 "2023-03-24T13:29:17Z")

</div>

Hi @r111

That should be doable on Bubble. Some rough steps:

It should be the index page otherwise it will be [mydomain.com/](http://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](http://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/](http://mydomain.com/)[`(do a search for user` / `current user`)’ slug]

That will directly give you a clickable link - [mydomain.com/userslug](http://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 🙂

 ![Rohan](https://us1.discourse-cdn.com/bubble/original/3X/4/a/4ab2457f2a9549157d3773799e3114a7ca7c27fe.png)  
[**Parshva**](https://parshva.io) | [**Book a call**](https://parshva.io/call)

---

<div class="post-metadata">

**Author:** ![r111](https://avatars.discourse-cdn.com/v4/letter/r/779978/32.png) [@r111](https://forum.bubble.io/u/r111)\
**Post date:** [March 24, 2023, 4:03pm UTC](https://forum.bubble.io/t/dynamic-links-how-to-redirect-if-a-page-doesnt-exist/253294/3 "2023-03-24T16:03:10Z")

</div>

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:  
[mydomain.com/index/user-slug](http://mydomain.com/index/user-slug)

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!  
Rob

---

<div class="post-metadata">

**Author:** ![rohanjainneri](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/rohanjainneri/32/210872_2.png) [@rohanjainneri](https://forum.bubble.io/u/rohanjainneri)\
**Post date:** [March 24, 2023, 4:15pm UTC](https://forum.bubble.io/t/dynamic-links-how-to-redirect-if-a-page-doesnt-exist/253294/4 "2023-03-24T16:15:00Z")

</div>

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](http://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](http://mydomain.com/user-slug) but the domain will redirect it to [mydomain.com/u/user-slug](http://mydomain.com/u/user-slug)

Regards

 ![Rohan](https://us1.discourse-cdn.com/bubble/original/3X/4/a/4ab2457f2a9549157d3773799e3114a7ca7c27fe.png)  
[**Parshva**](https://parshva.io) | [**Book a call**](https://parshva.io/call)

---

<div class="post-metadata">

**Author:** ![r111](https://avatars.discourse-cdn.com/v4/letter/r/779978/32.png) [@r111](https://forum.bubble.io/u/r111)\
**Post date:** [March 24, 2023, 7:15pm UTC](https://forum.bubble.io/t/dynamic-links-how-to-redirect-if-a-page-doesnt-exist/253294/5 "2023-03-24T19:15:36Z")

</div>

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 🙂

Have a great weekend,  
Rob

---

<div class="post-metadata">

**Author:** ![osintltd](https://avatars.discourse-cdn.com/v4/letter/o/5f9b8f/32.png) [@osintltd](https://forum.bubble.io/u/osintltd)\
**Post date:** [April 4, 2023, 8:51am UTC](https://forum.bubble.io/t/dynamic-links-how-to-redirect-if-a-page-doesnt-exist/253294/6 "2023-04-04T08:51:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![loic.gallouedec](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@loic.gallouedec](https://forum.bubble.io/u/loic.gallouedec)\
**Post date:** [April 4, 2023, 1:28pm UTC](https://forum.bubble.io/t/dynamic-links-how-to-redirect-if-a-page-doesnt-exist/253294/7 "2023-04-04T13:28:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [June 2, 2023, 10:01am UTC](https://forum.bubble.io/t/dynamic-links-how-to-redirect-if-a-page-doesnt-exist/253294/8 "2023-06-02T10:01:21Z")

</div>

Closed on June 2, 2023, 10:01am UTC

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