1

I have two rules in my .htaccess file. First is to hide extensionas of all files in parent, and second is for removing .php values and file id and also to "create" and display that URL in subfolder subfolder. The problem is that files in subfolder can't load .css and .js files since they are in parent/css and parent/js folder. I get: "Failed to load resource: the server responded with a status of 404 (Not Found)". Can't find any rule to change path or maybe exclude that css/js files.

This is my folder structure:

/parent/
|__ .htaccess
|__ index.php
|__ about.php
|__ details.php
|__ CSS
|  |__style.css
|__ JS
|  |__script.js

Theese are my rules:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/]+)$ $1.php
RewriteRule ^subfolder/([^/]+)$ /parent/details.php?value=$1 [L]

1 Answer 1

1

Insert this rule are the top of your .htaccess:

RewriteRule ^(?!parent/)[^/]+/((?:CSS|JS)/.+)$ /parent/$1 [L,NC,R]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.