Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

naresh-io's avatar

Rewrite url problem

I've a domain purchased on one domain and hosting from another provider. So, I've pointed the DNS and I'm using subdirectory as root of a site. My DNS is reaching the subdirectory when I access the domain www.example.com, but when I access www.example.com/home it is returning 404 error. What could be the reason? please help me with the possible reference or solution.

0 likes
10 replies
Snapey's avatar

dns won't get you to a subdirectory, only to a subdomain, i.e. the part before example.com

so, assuming you have set dns for www.example.com, how have you installed your website. what have you copied where?

naresh-io's avatar

@Snapey Sorry, I don't understand what you've explained. Actually this is my domain www.apopa.in and if I access www.apopa.in/home or any other link in that domain except www.apopa.in, it is returning 404.

Thyrosis's avatar

A 404 means that you do get to your server, but the file is not found.

What do you get when you visit www.apopa.in/public ?

Snapey's avatar

what I mean is that there is nothing you can do with dns to get you to www.apopa.in/home - only to www.apopa.in

to get to /home you need either a route /home in your application or a folder called /home with content there

1 like
naresh-io's avatar

@Snapey thank you for the explanation. I've the route to /home and content there.

Snapey's avatar

ok, so you need to take the site offline and change your database password etc since your .env file is exposed

Snapey's avatar

you need to make sure that all the laravel framework is in a private location

1 like
naresh-io's avatar

@Snapey thank you very much, I was just playing around how it works and forgot to change the permissions.

Snapey's avatar

it's not about permissions, it's about in what folders you install the framework

Snapey's avatar

when your host provides the site there will be a folder like wwwroot or public_html. Don't put your content in there, put it in the root space that the provider gives you and copy your public folder content into that wwwroot or public_html folder

1 like

Please or to participate in this conversation.