Page 1 of 1

What's the best method for clean URLs?

Posted: Tue May 05, 2009 5:30 pm
by WithHisStripes
Heya,
So I'm trying to convert:

http://www.mywebsite.com/?title=page-title-goes-here

- to -

http://www.mywebsite.com/page-title-goes-here

I'm looking for a dynamic way of doing this so anytime the user goes to "page-title..." it keeps the clean URL but tells my PHP that "page-title..." is ?title...

Does this make sense? Thanks!

Re: What's the best method for clean URLs?

Posted: Tue May 05, 2009 6:00 pm
by Defiline
You should use Mod Rewrite.
.htaccess:

Code: Select all

 
RewriteEngine On
 
RewriteRule ^([-a-zA-Z0-9]+)$ index.php?title=$1
 

Re: What's the best method for clean URLs?

Posted: Tue May 05, 2009 6:10 pm
by WithHisStripes
Okay - so I've been trying that method but I must be doing something wrong.

So I enter:

Code: Select all

 
RewriteEngine On
 
RewriteRule ^([-a-zA-Z0-9]+)$ index.php?title=$1
 
Then what URL do I go to to visiti http://www.sample.com/?title=sample ?

Thanks!

Re: What's the best method for clean URLs?

Posted: Tue May 05, 2009 6:15 pm
by Defiline

Re: What's the best method for clean URLs?

Posted: Tue May 05, 2009 6:18 pm
by WithHisStripes
Whoops, my mistake.

I was uploading .htaccess somewhere other than it belonged.

Thanks!