tags:

views:

34

answers:

2

Hello.. At the root of my site... www.domain.com . want to add some static pages that the page url can be set from the user. So if the users set as url profile then full page url should be www.domain.com/profile .. So far a simple rewrite rule would do the job. trasnlate it to something like /staticpage.php?tag=profile

The problem that i want some pages like www.domain.com/shop at the root which arent static... So what can i do if all the requests for the main directory go to /staticpage.php?tag=$1 ?

+1  A: 

I recommend using mod rewrite to send everything to your index.php file and using a front controller to do this. It makes it much easier.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
</IfModule>
Galen
Inspect `$_SERVER['REQUEST_URI']` to determine how to route the request to the correct controller or PHP file.
meagar
A: 

You'll find a lot more help about mod_rewrite on ServerFault as a general rule, but I tend to do this:

RewriteEngine on
RewriteRule     ^static.*$   -       [L]
RewriteRule     ^assets.*$   -       [L]
RewriteCond     %{REQUEST_FILENAME}   !-s
RewriteRule     .*      /router.php

where "static" are uploaded files, and "assets" are production graphics/stylesheets/js libraries etc.

Aquarion