View Full Version : user friendly URL, how ? :(

03-04-2008, 06:58 PM
I m using a script which is in php+smarty method.
so when it recives $_GET command like " ?page=home " it loads " home.tpl " .

now I wanna use something user freindly URl for this script.for ex :

www.example.com/?page=test ==> www.example.com/test/

what should I do

Thanks for ur great help. :D

03-04-2008, 07:34 PM
You usually use Apache's mod_rewrite via the .htaccess file. Here is a decent cheat sheet (http://www.ilovejackdaniels.com/mod_rewrite_cheat_sheet.png). If you have never used mod_rewrite it can be a little confusing, but there are a lot of guides out there you can search for, and if you get stuck there are a lot of knowledgeable people on this forum. It usually helps if you know regular expression syntax, but it's not required.

03-04-2008, 08:13 PM
I tried this 1 , but doeant work

RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 [L]

03-04-2008, 09:09 PM
I tried this 1 , but doeant work

What exactly doesn't work? Make sure the .htaccess file is in your document root. Also, try replacing [L] with [QSA,L].

03-05-2008, 03:35 PM
I mean it doesnt change the url. the URl remains as its original :(

03-05-2008, 03:40 PM

03-05-2008, 04:04 PM
mod_rewrite is enabled here.
it was my fault, I Thought if I use ?page=test it should redirect to /test/
but I tried /test/ and it loads the ?page=test, its fine , but

1- non of the links wrok in pages :(
I mean non of the images load, or the CSS link doesnt work, and pages are just text :(
the source links are changed like :
http://domain/images/top.gif is changed to http://domain/faq/images/top.gif
it means that I should creat a folder for each page ?

2- after the user logins , in member area , if we try for example "/profile/" which has to show " ?page=profile" the script, logs out from member area, the pages inside member area, after login , are not accessable


03-05-2008, 07:07 PM
1) http://www.w3schools.com/tags/tag_base.asp

<base href="http://www.domain.com/" />
Place that in the header and it will dodge the relative file paths. (obviously change it to your domain though)

2) No idea. Provide some code?

03-05-2008, 09:50 PM
I'd read this article (http://datakoncepts.com/seo) to get a better understanding of mod rewrite.

03-07-2008, 07:52 AM
Thanks all
best forum around :thumbsup:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum