Red Acid
Red Acid

Reputation: 217

htaccess - load files on fake path

I have the following code on my .htaccess file:

RewriteRule    ^([0-9A-Za-z]{12})(\/.+|\.html?|$)  /stuff/index.cgi?etc=dostuff [L]

with this rule people can access urls like:

http://domain.com/by6xq1ybc7zz/something.html

I want to include css, js, php on fake path /by6xq1ybc7zz

right now I have to load my files from the parent directory. I want to load the files from the current directory.

right now I have to load files from parent directory:

<script type="text/javascript" src="../script.js"></script>

But I want to load files on the current directory:

<script type="text/javascript" src="script.js"></script>

So how I can include files in this fake directory?

http://domain.com/by6xq1ybc7zz/[STORE MY FILES ON THIS FAKE DIRECTORY]

Upvotes: 1

Views: 1263

Answers (1)

anubhava
anubhava

Reputation: 785286

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^[0-9A-Za-z]{12}/([^.]+\.(?:js|css|php))$ /$1 [L,NC]

# your existing rule
RewriteRule ^([0-9A-Za-z]{12})(/.+|\.html?|$) /stuff/index.cgi?etc=dostuff [L]

Upvotes: 2

Related Questions