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

Posted July 11, 2015 1.8k views
UbuntuApacheLAMP StackNetworking

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:[](http://) 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 [](http://) it gives me a 404 error that it cant find that file. But if i type [](http://) 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 :)

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.

Submit an Answer
1 answer