Jump to content

questions about using include() in php


sudhakararaog

Recommended Posts

i am doing seo for a website and this website uses a lot of php for which i need suggestions. this is how the website is set up.

 

in the index.php file there is a flash banner at the top of the page and the center part is another file which is called using include("links.php") and the bottom part using include("footer.php")

 

the footer has links such as = webdevelopment software development ... each of this has a query string= http://website.com/index.php?page=webdevelopment and http://website.com/index.php?page=software ... etc

 

this way every link in the website is calling index.php and a query string is being passed and the index.php looks for the name ex=webdevelopment and loads that particular page in the center section of the website. the main purpose of doing this was to load the flash file only 1 time and the rest of the time when the links from the footer are clicked only the center part changes and the flash file does not have to reload.

 

due to this the entire website is having only 1 page index.php therefore using 1 <title> tag 1 meta description and 1 meta keywords tag as the values of <title> and <meta> tags are being displayed from index.php

 

however from a seo and sem perspective ideally there should be different file name which means i can optimize the <title> and <meta> tags for individual files.

 

please advice a best solution to get around this as i would like to have different title and meta tag for individual pages like webdevelopment.php software.php etc which i am presently not able to due to include("")

 

any help will be greatly appreciated.

 

thanks.

Link to comment
Share on other sites

What you have currently is a very common pattern, referred to as a fusebox, junction box, front controller etc.  There's nothing wrong with it. 

 

It seems you have 2 questions:

 

1. How to have different header content.

 

Add a case statement at the top of index.php that emits whatever you want in the html HEAD section based on the same "page" parameter that's being used to include the section in the middle.

 

2.  How to have "search friendly urls"

 

There are a variety of ways to do this, but the most common one with apache is to utilize the abilities of mod_rewrite to convert your urls from what they actually are, to something that looks hardwired.

 

Your goal then would be to:

 

a) make sure that all requests get routed to your index.php

b) break up the url into pieces and rewrite it so that the first directory after the url gets converted to the page= parameter

 

This would allow you to then have url's that look like this:

 

http://website.com/software

 

There's many examples of how to do this, and lots of FOSS software like Joomla, Serendipity, Wordpress etc etc etc that have examples of how to write the needed mod_rewrite rules.  Often they are stuck into .htaccess files.

Link to comment
Share on other sites

I thought they needed to be in .htaccess files.

For mod_rewrite, check out this helpful article:

http://www.workingwith.me.uk/articles/scripting/mod_rewrite

 

No, you can put them into the config file directly or into a a vhost section.  For a lot of people, that's not an option as they are working in a hosted environment where modifying those files is impossible.  With that said, if you have your own server, it's the best solution performance wise. 

 

FOSS projects offer the .htaccess approach because those sorts of rewrites are typically an option that can be turned on or off depending on the support for it.  Not everyone uses apache.  I should also add that mod_rewrite is not the only approach and you can get much of the same effect by manipulating the uri inside your PHP script.  Those variables are available in the web environment in the $_SERVER superglob, and that code will work with most any PHP install regardless of the webserver.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.