Trying to create friendly urls

New to mod_rewrite? This is a good place to start.

Trying to create friendly urls

Postby partdigital » Wed Jun 10, 2009 10:47 am

Ok, so here's what I'm trying to do.

I'm creating a game website which is organized by folders.

The main sections sections exist on the main directory.
example: public_html/about/

The game sections exist in a games directory
example: public_html/games/worldofwarcraft

Using mod rewrite I've been able to go to the games directory without having to type in "games" in the url.

example:

www.domain.com/worldofwarcraft/ goes to www.domain.com/games/worldofwarcraft/

Now, when I go to the home page I want it to redirect to public_html/home/ but instead it's being redirected to public_html/games/home/ where it obviously returns an error.

Here is my code:
Code:
Code: Select all
Options + FollowSymlinks
RewriteEngine on

RewriteCond $1 !^(games|layout|about|contact|affiliate_program) RewriteRule ^(.*) games/$1 [L]



Did you guys have any suggestions on how to do this?
partdigital
 
Posts: 1
Joined: Wed Jun 10, 2009 10:44 am

Postby richardk » Wed Jun 10, 2009 1:27 pm

When the user visiting example.com should they be visibly redirected to example.com/home/?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^$ /home/ [R=301,L]

RewriteCond $1 !^(games|layout|about|contact|affiliate_program|home)(/.*)?$
RewriteRule ^(.+)$ /games/$1 [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 114 guests

cron