I’m making a project using iWebKit. I When I include the files, I don’t want to have to keep linking back to the directory the framework is in like:
<link href="css/style.css" rel="stylesheet" media="screen" type="text/css">
<link href="../css/style.css" rel="stylesheet" media="screen" type="text/css">
<link href="../../css/style.css" rel="stylesheet" media="screen" type="text/css">
<link href="../../../css/style.css" rel="stylesheet" media="screen" type="text/css">
I want to be able to have the same directory in every other directory so localhost/css/style.css is the same as localhost/some/other/directory/css/style.css.
I am using Apache and want to know if there is a way to do this with .htaccess
You can do this my using mod_rewrite
For this add the following to the .htaccess file in the root of your application
Here the Regular Expression
^.*/css/([^./]*)\.css$matches any string with /css/any_name.css in the end, and rewrites the URL to point internally to css folder in the root. And [L] means it is the last rule to match if it matches. And $1 refers to the parenthesized portion of the Regular Expression that matches the URL, which is the name of the stylesheetFor more complex scenarios I would suggest you read up some more on the internet.