Can't access some files after changing the root using .htaccess

My website contains all the public files in my htdocs/public folder. I used .htaccess to change the root and it did work. But some valid and existing files are not accessible throughout the website. exists and it works. at the same time exists too but when you open it, it returns a 403 error.

Same issues with some files…

Including .htaccess with the topic.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^$ [NC,OR]
RewriteCond %{HTTP_HOST} ^$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]

Did i made a mistake, Any help would be appreciated…!!!

Thanks :blush:

1 Like

If you are using Cloudflare, then I reccomend using “HTTPs rewrites” and “Redirect all traffic to https” settings, if not then i would say yoink the code out

I looked at your site. It works fine.

I cannot sign up to your site

After doing so, I get a 403 error

Thanks for your advice,

But its all about changing the root, i have any SSL certificate yet and i guess i didn’t provide any Rules in htaccess to make the connection HTTPs. Although the processing file for Registration cannot be opened mean while processing file for login could be opened. Im pretty sure that its working on my localhost.

You could just visit these links. First link doesn’t work meanwhile second link does output what it was required to do.

And of course, i will put those title tags…!!!

When i try to sign up

Are you using Laravel?
And where does register.php send data when you try to register? (i mean what page)

What is that

Yes, Exactly because the processing page is not found. And its quite confusing as it exists in the correct path.

Why not just Googling what it is?

1 Like

cos i use duck duck go

1 Like

No, Im using php with some extra libraries like Symfony/http-foundation along with doctrine DBAL.

And it works in localhost as well as in my friends paid host where he changed his root path using cPanel. And it works

Googling is mainly being used for Searching a thing on internet, let’s don’t take the topic to off topic

1 Like

I think the issue is because of your htaccess file. Can you try to use this one?

RewriteEngine On
RewriteRule (.*) /public/$1 [L]
1 Like

Yea, i am not familiar with .htaccess rules. But it should work… isn’t it

I’m not sure about the details, but I think that this may be a security rule taking effect because of the URLs. A folder modules is also commonly used to store libraries and other pages which should not be accessed directly. But I can’t quite explain why modules/login.php does work but modules/register.php does not.

In any case, renaming the folder should be the easiest fix.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.