GorillaApe
GorillaApe

Reputation: 3641

Mod rewrite problem

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 ?

Upvotes: 0

Views: 73

Answers (2)

Aquarion
Aquarion

Reputation: 591

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.

Upvotes: 0

Galen
Galen

Reputation: 30170

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>

Upvotes: 1

Related Questions