naviciroel
naviciroel

Reputation: 412

.htaccess url secure

Hello everybody :D I would like to ask for your help on this problem. I have a .htacess and I want to make my files secure. I want to make a url for my css to different from its original path. Its like hiding the directory of the css or removing it from the url but still when the browser fetches the file it points to the write file path.

Example

Orignal path

Directory: /public_html/styles/main.css

Web URL: www.domain.com/styles/main.css

What I want:

Directory: /public_html/styles/main.css

Web URL: www.domain.com/main.css

Upvotes: 0

Views: 150

Answers (2)

Your Common Sense
Your Common Sense

Reputation: 157919

I would like to ask for your help on this problem.

I don't see any problem here.

I want to make my files secure.

It just makes no sense. CSS files intended to be "insecure", i.e. accessed by everyone.

I want to make a url for my css to different from its original path.

It makes no sense again. Hiding directory path doesn't make the file secure.

Upvotes: 2

Jon Lin
Jon Lin

Reputation: 143906

Make sure you have mod_rewrite and put this somewhere close to the top of your .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.css$ /styles/$1.css [L]

Upvotes: 0

Related Questions