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

July 11, 2015 1.2k views
Apache Networking LAMP Stack Ubuntu

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 :)

1 Answer
Have another answer? Share your knowledge.