Can anyone tell if this would work?

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

Post Reply
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Can anyone tell if this would work?

Post by ianhull »

Hi Guys,

I have had a look at mod_rewrite but I dont really want to go down that path.

I was having a think about how to make SEO friendly urls and I am wondering if there is anything I have overlooked.

My system is all database driven.
When a new record is entered into my DB I was thinking of creating a directory using php using the recordID and generating a index.php page

Then on my generated links instead of using my.php?item=
use http://www.domain.com/9778564

Then in my index.php page get the current directory from the address bar using javascript and the query my database relating to the directory name against the recordID

would this keep all my urls neat and tidy and SEO friendly?

is there anything I have overlooked?

Thanks in advance.
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

although its pleasing to the eye, having numeric ids in the url isn't really seo friendly.

SEO friendly urls would be like...


http://www.domain.com/232343/Blue-Shirt-Cheap.html


something like that using a short description in the url.

end the url with .html so that the search engine thinks its a static page, not necessarily important, but a nice touch. Otherwise, you can just mod_rewrite according to just the digits, the other stuff can be ignored.

A page that is like http://www.domain.com/232343/asdasdasdas.html would then reference the same page.
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Thanks for the advice, much apreciated.

After doing some research on SEO I have decided to not have any extention on any of my pages.

I understand what you mean about the numeric values as pages, this could maybe not be so good so I have decided to use the page title from my database instead of the RecordID

Kind regards
Ian

Anyone else think of anything more to add to this post please feel free,

the more advice and suggestions the better.

Thanks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Why don't you want to use mod rewrite? It would make things much simpler than what you are suggesting. Infact, your method is extremely complicated in comparison.

Is it because you don't understand mod rewrite?

On a side note, search engines are usually up to date with query string, and see http://domain.com/?id=3234324 the same as http://domain.com/3234324
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

I have had a look at the mod_rewrite but decided against it as my main objective is to build a system which not contain any variables and values on any a href links on my pages or address bar.


Here's how I see my system working.

MySQL

RecordID
PageTitle
PageContent
PageCreated

When a new page is created from the admin section I will use mkdir to create a directory based on the value of PageTitle

I will then copy a file index.php from another location on my server to this new directory.

The index.php file will contain javascript to get the current directory and then query the database WHERE PageTitle='PageTitle'

Thanks for any advice or suggestions.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

ianhull wrote:I have had a look at the mod_rewrite but decided against it as my main objective is to build a system which not contain any variables and values on any a href links on my pages or address bar.
Filesystem http://domain.com/34982304832
ModRewrite http://domain.com/34982304832

I don't see any difference :roll:
ianhull wrote: Here's how I see my system working.

MySQL

RecordID
PageTitle
PageContent
PageCreated

When a new page is created from the admin section I will use mkdir to create a directory based on the value of PageTitle

I will then copy a file index.php from another location on my server to this new directory.

The index.php file will contain javascript to get the current directory and then query the database WHERE PageTitle='PageTitle'
All this can be done using a single index.php file... and just for your information, there is no need to use javascript for this. I recommend you take a look at

Code: Select all

echo '<pre>';
print_r($_SERVER);
echo '</pre>';
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

now thats interesting

Could you tell me how this would work.


mod_rewrite???

I do not know where to place this, when I looked I assumed it was to go into httpd.conf Apache2


From my database I create a paginated result containing links


Query...

Code: Select all

<a href="'.$pagetitle.'">'.$pagetitle.'</a>
Thanks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

First, can you show me how all your links will look in the end? (the ones you want mod_rewrite to capture)
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

my links will look like this

reports.php?pagetitle=Safety Alert
reports.php?pagetitle=Fire Safety

etc

Thanks Jcart
Post Reply