Web Hosting Talk







View Full Version : [PHP] Create a ?x=page navigation system


arkdm
07-18-2006, 10:36 AM
I just found another cool article from Codeless! This one shows how to create a ?x=page nav system. Really helped me with my site:

http://codeless.org/showthread.php?t=595

NyteOwl
07-19-2006, 09:38 PM
Most people are trying to get away from that type of nav as it isn't as friendy for search engines, why would you want to deliberately implement that nav.

Just curious.

zargon
07-19-2006, 09:49 PM
I'd like to see what the end HTML looks like. I'm not an SEO expert but I wonder if a search engine could consume that...

Johnny

arkdm
07-19-2006, 10:40 PM
I find the nav to be a bit easier to work with. Never really thought about SEO. I'd also be interested to see how it turns out.

sea otter
07-20-2006, 12:21 AM
You can solve the SEO problem by using mod_rewrite.

Visitors enter something like "yoursite.com/page" in their browsers, which mod_rewrite then converts into "?x=page" for your code, which then processes it in the manner described in the article.

RobertMaltby
07-20-2006, 01:33 AM
You can solve the SEO problem by using mod_rewrite.

Visitors enter something like "yoursite.com/page" in their browsers, which mod_rewrite then converts into "?x=page" for your code, which then processes it in the manner described in the article.

You can use the following .HTACCESS Codes for that:


RewriteCond %{REQUEST_URI} ([a-z\-]+)\.html$ [NC]
RewriteRule ^(.*)\.html$ index.php?x=$1 [L,QSA]


Turns index.php?x=page into page.html

**Im not the best at this, but Im still learning it myself...

sea otter
07-20-2006, 11:50 AM
Platinum23, nice catch with the QSA. Lots of people don't know about it and end up avoiding mod_rewrite because they think they'll lose the query string.

You could also use something like this:


RewriteEngine On

#ignore existing files and directories
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9-]+)/? /index.php?x=$1 [L,QSA]