0
votes

I'm changing my Drupal site from www.example.com/demo to www.example.com. The resources like js, css etc still lives under "demo" folder. What should be the Rewriterule or Alias that is required to achieve this change?

I currently have this setting in my .htaccess file

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ /

1
why don't you copy that resources outside the demo folder?Ben
there are other folders outside and for better organization of large number of files within the demo folder, i want to keep it inside the folder.neelmeg

1 Answers

0
votes

You should have these rules to test whether the files exist to the demo folder, and rewrite the URL if it does.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/demo%{REQUEST_URI} -f 
RewriteCond %{REQUEST_URI} (\.js|\.css)$
RewriteRule ^(.*) /demo/$1 [QSA,L]

Line 1: Test if the request file not exists in root folder

Line 2: Test if the request file exists in demo folder

Line 3: Test if the request file end with js / css extensions (change to suit your case)

Line 4: Rewrite the URL to request the file inside the demo folder