1

I've been having problems trying to set up my .htaccess for the site.

I am trying to remove a folder from the URL when a page accesses this. I managed to successfully remove the folder from the path using this post How can I remove this directory/folder from url with htaccess rewrite? but when I load the page up, none of the css, javascript or other resources are loaded correctly.

When I try to access the resource from the url it says 'The requested URL /modules/content/styles/default.css was not found on this server.'

Modules is the folder I am trying to remove when accessing a page, however it seems that when I added the code to htaccess, it's adding "modules" to all paths.

My file structure looks like this

enter image description here

I have a .htaccess file in the root directory with the code:

RewriteEngine on
RewriteRule !^/?modules modules%{REQUEST_URI} [L,NC]

I also have one in the modules folder with the code:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+modules([^\s]*) [NC]
RewriteRule ^ %1 [R=301,L]

I have tried multiple solutions but all end with "Page not found", this is the closest I have gotten but now I am having a problem with resources.

Any help would be great!

Community
  • 1
  • 1

1 Answers1

0

You need to change this rule in root .htaccess:

RewriteEngine on

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^modules/ modules%{REQUEST_URI} [L,NC]
anubhava
  • 761,203
  • 64
  • 569
  • 643