Forum Moderators: phranque

Message Too Old, No Replies

.htaccess parsing on subdirectories

Having trouble applying parsing on lower directories

         

chichospunk

6:39 pm on Jan 17, 2008 (gmt 0)

10+ Year Member



I've created a custom header on html and have added the necessary code to my pages so they load it. Everything works fine if the header file is in the same directory as the requested page, but it wont work when I try to load this same header on other directories of my page and don't know what is the appropiate line on my htaccess file to do this.

Thank you for your help.

Chris

jdMorgan

1:56 pm on Jan 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



May we see the "header" definition/invocation you're using? The key is probably to do with *how* you are referencing the header.

Jim

chichospunk

2:54 pm on Jan 18, 2008 (gmt 0)

10+ Year Member



The way I call my header file is like this:

<!--#include file="headeren.html" -->

This is when my header file is on the same directory as the page I want to load. The structure I would like to have since it is a multi language site is to have a directory exclusively for headers and footers and a different one for each language and the way I'd call the header file would be like this:

<!--#include file="../headers/headeren.html" -->

This call displays fine on Dreamweaver aplying the Server Side Include on the Insert Menu, but when I try to see it online it wont display and gives me this message on top of the page instead of my header:

[an error occurred while processing this directive]

Thank in advance.

Chris

jdMorgan

3:36 pm on Jan 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Be aware that mod_rewrite has no effect on server-side "file" includes, since they are local filesystem accesses, and do not use HTTP. Code in .htaccess only applies to HTTP requests, not filesystem accesses and not FTP.

Also, the mod_include documentation [httpd.apache.org] recommends using "include virtual" instead of "include file":

Include file
The value is a path relative to the directory containing the current document being parsed. It cannot contain ../, nor can it be an absolute path. Therefore, you cannot include files that are outside of the document root, or above the current document in the directory structure. The virtual attribute should always be used in preference to this one.

I would recommend:


<!--#include virtual="/headers/headeren.html" -->

This may or may not work with your local DW development tools, but it will work on the server. Using a server-rooted path as shown eliminates the need to keep track of the current directory level using "file.inc", "../file.inc", "../../file.inc", etc.

If DW does not work with that approach, then it will not work using .htaccess to "correct" the paths, either; You'll either need to install a local server for testing, or use the virtual relative ("../") paths.

Jim

chichospunk

8:14 pm on Jan 25, 2008 (gmt 0)

10+ Year Member



Thanks Jim adding include virtual works great for all the text on the header files but when I have images like a menu bar in flash it wont show the actual image o movie maybe because the relative path is only applicable to the file in question.

Is there a way to change those relative paths when you call the file with include virtual so that the images and other interactive content is displayed?

Thanks

Chris