1

my .htaccess file contains the following

RewriteCond %{HTTP_HOST} ^www\.mydomain\.org\.in [NC]
RewriteRule ^(.*)$ http://mydomain.org.in/$1 [R=301,L]

I moved the whole site to a subfolder and now none of the css and js files in the webpage load. Can anybody tell me what this regex means or why this is happening?

Note: I inherited the site from my seniors :P

2 Answers 2

1

It just redirects any request to www.mydomain.org.in/... to mydomain.org.in/...; i.e. it strips the www from the front. However, this shouldn't cause the resource files to break if you simply move it to a subdirectory, assuming you've moved them as well (though you should probably leave the .htaccess file where it is).

It sounds like the links to your CSS/JS files in your HTML might be broken, perhaps because they use absolute URIs (relative to the domain root rather than the current URI). Try checking them first.

Sign up to request clarification or add additional context in comments.

Comments

0

As Will explained the .htaccess is not the issue. Your JS and CSS locations were mentioned not relatively and as such when the location of the source files changed they are not being found by the browsers and as such the page is not rendering.

However, you can try the following .htaccess code in addition to the one you are having and see if it links to the files.

RewriteRule ^(.+)\.css$ http://mydomain.org.in/folder/$1.css [R=302,NC]
RewriteRule ^(.+)\.js$ http://mydomain.org.in/folder/$1.js [R=302,NC]

The above code redirects calls to css and js files to a subfolder in your domain. Change folder to the folder you moved everything to.

2 Comments

This may work, but it wouldn't fix the underlying problem, and it'd require changing if the folder were to change. It also generates redundant HTTP requests; he best solution is just to tell the browser to look in the right place to start with.
I know Will but he requested .htaccess, regexp, redirect, mod-rewrite assistance :) Apparently he is in search of a less time and manpower resource intensive resolution. He seems to have good servers that will not be bothered by the additional HTTP requests for the CSS and JS files.

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.