Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Mod Rewrite help

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch

firestorm

Established Member
Impact
6
Hey all,

I'm trying to wrap my head around a site I am working on. All of the content is in a mysql database set up (mini-sites ->pages in site -> content blocks)

I'm stuck over how to get each page to appear in the url. If I had 3 pages, say home about and contact i would want them to be:
url.com/
url.com/about/
url.com/contact/

I have 1 index page (template) so far, and I would like the url to go to that page and affect which page table i get in the query. Would this be done with mod-rewrite?

Any pointers would be great!
Thanks.
-fire
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
A mixture of mod_rewrite and php. Your .htaccess could read something like:
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [L]

Then url.com/about is the same as url.com/index.php?page=about.

You can then set up your queries using $_GET.
PHP:
Code:
if ($_GET['page']) {
   mysql_query("SELECT content, headings, etc FROM minisites WHERE name='" . $_GET['page'] . "'");
   mysql_fetch_array...
}

Does that answer your question?
 
0
Close
Yes it does! Thanks, I just couldn't grasp it earlier for some reason. Will work on that this today then.
Thanks again.
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back