How do i secure my folders and use mod_rewrite for rewriting URLS

Hello there! I just set up a droplet and so far i’m loving it. But i have two problems thats preventing me to launching my new site. I have a little knowledge of servers and vps servers but i’m not a pro at all haha. The first problem i’m having is that people are able to view my private files. For example they can type this in the url field: and they can see everything in there. I cant figure out the mod_rewrite statement to make sure that when people try to access those urls that they are redirected or something

The second problem i have is with my .htaccess. My site is a custom made MVC website and it relies on .htaccess. All of the other pages work except the “index” page. When i type it gives me a 404 error that it cant find that file. But if i type it gives me the correct page.

This is how my .htaccess file looks:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?u=$1 [L]

I also used this command in my ssh terminal:

 sudo a2enmod rewrite

If someone can help me with these two problems, that would be great :)

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This comment has been deleted