mod rewrite issue

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

mod rewrite issue

Postby mrtricksta » Mon Jul 13, 2009 12:22 pm

Hi, i have an issue with some htaccess mod rewrite code, what i need the script to do is redirect http://www.domain.com/username to http://www.domain.com/profile.php?user=username which i got working but i need a exception if the page is for example http://www.domain.com/signup or http://www.domain.com/help

Currently i have this

Code: Select all
ErrorDocument 404 http://domain.com/

RewriteCond %{HTTP_HOST} !^domain\.com

RewriteRule ^(.*)$ http://domain.com/ [R=302]

RewriteEngine on

RewriteCond %{REQUEST_URI} !help

RewriteRule ^([^/\.]+)/?$ profile.php?id=$1 [L]


Which kind of works but it goes to a sub folder which isn't what i want really

can anyone help???
mrtricksta
 
Posts: 1
Joined: Mon Jul 13, 2009 12:17 pm

Postby richardk » Wed Jul 15, 2009 12:51 pm

Are /help and /signup directories or are you going to use mod_rewrite for those URLs too?

Try
Code: Select all
ErrorDocument 404 http://example.com/
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

RewriteCond $1 !^(help|signup)$
RewriteRule ^([^/\.]+)/?$ /profile.php?id=$1 [L]


Which kind of works but it goes to a sub folder which isn't what i want really

What URL? What sub directory?
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 90 guests

cron