I
I
ingenerdsm2014-02-10 15:36:06
htaccess
ingenerdsm, 2014-02-10 15:36:06

RewriteRule in htaccess and relative file paths

Hello, I have a problem with the htaccess file on the site, there is a category
folder (located at the root) and the page.php page is located in it , respectively, this page is available at the url: site.com/category/page.php, I want to change the url through htaccess , so that the page becomes available at site.com/contacts.html Accordingly, I write the following in htaccess:

RewriteEngine On
 
RewriteBase /
 
RewriteRule ^contacts\.html$ category/page.php [NC,L]

I get the result: the page becomes available at: site.com/contacts.html
But for some reason, part of the js and css files is not connected. The main.css
file , which is located at the root and is connected to the page via a relative path - href="../ main.css" - Works A css file, which is located in the category folder (on the same level as page.php) and is also connected via a relative path - href="demo.css" - DOES NOT work , all js from the category folder is also not connected . Accordingly, without making changes to htaccess, everything is fine. It will also work if css and js have a direct path (but this is not an option)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kudlayko, 2014-02-11
@kudlayko

apply path from site root
href="/category/demo.css"

K
kudlayko, 2014-02-13
@kudlayko

RewriteRule ^demo\.css$ category/demo.css [NC,L] =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question