0

I have been looking and looking around on the web for an answer for my question. But everything is just not the right thing.

So my issue is:

I'm creating my own CMS, and right now I've got the issue with the urls. They aren't really that SEO friendly.

When I create a new page, it gets the URL: index.php?page=(id). That doesn't tell much. So what I would love to create.

Is that I wan't the URL to be something like: www.myurl.com/home instead of the page=id. Is this possible?

I have to mention, that I need the id number later on, for editing the pages. I'm focusing the GET function to be able to edit my pages, and to show 'em one by one.

Thanks. :o)

3
  • 1
    Probably this is of use to you: When Flat PHP meets Symfony, it shows how that can be done. Commented Jun 18, 2011 at 12:50
  • 1
    I would just throw the id the url with home with a URL such as myurl.com/9/home. Google won't really care about the 9 in there, but it will like the home. We did this for www.obitsforlife.com and it worked great. Commented Jun 18, 2011 at 12:51
  • I like the myurl.com/9/home.. How are you doing this? :o) Commented Jun 18, 2011 at 12:57

2 Answers 2

1

Try to set your .htaccess file to the following:

RewriteEngine On
RewriteRule ^([^/]*).html$ index.php?page=$1 [L,NS]

this way you can translate what visitors see as yourdomain.com/home.html to what php reads as yourdomain.com/index.php?page=home afterwards you can of course use a translating array containing your id's

$translationArray("home"=>1, "contact"=>2);
$id = $translationArray[ $_GET['page'] ]; // $id now contains 1
Sign up to request clarification or add additional context in comments.

5 Comments

I dont want to change from .html to index.php?page=home .. I just want to change from: index.php?page=(id) to /home..
so if i understand correctly you want to rewrite yourdomain.com/home to yourdomain.com/index.php?page=1
The other way around. is my english that bad? lol ;o) This is how it looks now: myurl.com/index.php?page=1 and I want it to be: myurl.com/1/home for example. Like Zoidberg wrote.
Yes of course. But what you want .htaccess to do is exactly the other way around, it has to read /home and translate to the id stuff.. This way your visitors can just type /home, but your system will read this as index.php?page=1.. In my example the only difference is the .html after the /home.. leave it out the example and it should work. This: workingwith.me.uk/articles/scripting/mod_rewrite should help!
I will be back, telling if this was it. It looks like the URL you posted, is the thing. But right now, I'm having troubles connecting to FileZilla o.O
1

What you're looking for is called Semantic URLs. Other keywords that will aid you: .htaccess, mod_rewrite

A full solution is too complicated to expand upon here but the underlying idea is fairly simple.

2 Comments

I've made a search on Google and got: en.wikipedia.org/wiki/Semantic_URL is this what I am looking for? :o)
Yes. Wikipedia doesn't give you a practical solution though, but that is gist of it.

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.