.htaccess file causing Server Error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: .htaccess file causing Server Error

Post by twinedev »

Well, if you have something such as <img src="images/heading.png"> then yes, that is how it works.
Remember the request to load up the above image comes from the browser, it doesn't know how the server remaps. I thinks that the page is in the directory /page/selector and the above says "From where we are, look for images/heading.png

There are two solutions to it. the first is what I have always been in the practice of, from back in the day when you actually had big sited with static pages so you actually had them in different directories:

Provide the full path (absolute path) to the item from the root of the site, ie <img src="/images/heading.png"> then it does not matter where on the site the file is, it will always grab from the root of the site.

Second method, which I do not prefer as if you do not realize it is there, can mess with where you think things should be later on when you come back is to use the <BASE> tag
http://www.w3schools.com/tags/tag_base.asp

-Greg
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: .htaccess file causing Server Error

Post by simonmlewis »

I've just tried it with /images.... and it works nice. And would take less effort to redo it all.
What I have a problem with now is just one /word/.
ie. clienta.local/product/
in theory this should loadl index.php?page=product
But it doesn't. Hrere is the htaccess for it, with the ID part too.
DirectoryIndex index.html index.htm index.php
order allow,deny

allow from all

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^$ index.php?page=home&menu=home [L]
RewriteRule ^page/([^/\.]+)/?$ index.php?page=$1 [L]
RewriteRule ^product/([0-9][0-9])/$ index.php?page=product&product=$1 [L]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: .htaccess file causing Server Error

Post by simonmlewis »

If I do do the "page/" one, and do:
test.local/page/selector
it loads up page=selector.
But I cannot see how to make "test.local/selector" load it up instead?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply