Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess redirecting all URLs except one

I have a server running with the following directory structure:

/public_html
   | - /fingertools
   | - /css
   | - /static
   | - /media
   | - /js
   | - .htaccess

My .htaccess is in the root of the "public_html" folder, and the main files of the website are in the "fingertools" folder, which is a Django project.

I want to rewrite through the .htaccess all requests to http://mydomain.com/ to the "fingertools" folder, except any file inside http://mydomain.com/static/ should be redirected to the "static" folder.

I'm not able to do this, I need it to put all the CSS and JavaScript into this folder for the website to work.

I have this so far:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(fingertools)
RewriteRule ^(.*)$ fingertools/$1 [L]

Which redirects me to my Django project, giving me a 404 error for not having the /static/ URL mapped in the urls.py file. Any ideas? Thank you very much

like image 407
Bruno Finger Avatar asked Mar 25 '23 02:03

Bruno Finger


1 Answers

Options +FollowSymlinks

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_URI} !^/(fingertools|static)(/|$)
RewriteRule ^(.*)$ fingertools/$1 [L,QSA]
like image 130
Zenexer Avatar answered Mar 31 '23 21:03

Zenexer