0

I am working on a website in a CMS site. I have provided a link in my footer file e.g blogs.php. This page is at the root like "http://www.example.com/new_cms/blogs.php"

When I moves to other files link like "http://www.example.com/new_cms/forums" the footer link is changed to "http://www.example.com/new_cms/forums/blogs.php" but the blogs.php page resides at path "http://www.example.com/new_cms/" . I tried different $_SERVER[] variables but got no luck to get the above path "http://www.example.com/new_cms/" means the server name with the directory where the project is currently running from.

Any one have idea how to get it done will be a great help.

Thanks

1
  • can you please provide the code that you are using to display the link? You can edit it into your question for us. Commented Jun 14, 2010 at 7:56

3 Answers 3

2

This is probably because your link has a relative url in it, like so :

<a href="blogs.php">Blogs</a>

So it looks for the blogs.php file in the current directory.

If you want that link to point to the blogs.php file that is in the new_cms folder, you have to use a link like this :

<a href="/new_cms/blogs.php">Blogs</a>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Friends for all of your help :) I think I have to use the static path of the directory inside my www root site directory.
0

You can use absolute URL or try to rewrite your url with a condition.

Comments

0

You can obtain the server name from $_SERVER['SERVER_NAME'] that is the canonical server name specified in the server/virtual host configuration. Besides that $_SERVER['HTTP_HOST'] gives you the host specified in the HTTP request header field Host. In general, these two values are identical. But since both can be manipulated by user input (see Chris Shiflett’s SERVER_NAME Versus HTTP_HOST) you need to be careful when using these.

As for the path, you will probably need to specify the base URL path on our own. Because if you think of URL rewriting techniques, the physical path (file system path) does not need to be the same as the logical path (URL path). So you can not derive the logical base path from the requested URL path, the script file path and the document root.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.