Connecting Tech Pros Worldwide Forums | Help | Site Map

How i can have a .htaccess like twitter.com?

Newbie
 
Join Date: Jun 2009
Posts: 16
#1: Jun 29 '09
Hi

I wanna have a htaccess file that when i go to "www.domain.com/sometext" the page redirect to "www.domain.com/user.php?user=sometext". It's important that is better that URL not end with slash. I have a problem with my htaccess file:

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2. RewriteRule ^(.+)$ user.php?user=$1 [L,R]
But when i go to to "http://localhost/jack" the page will redirect to "http://localhost/user.php?user=user.php".

I have read this topic, but is it possible that "user" phrase doesnt exists after "^" character?

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 5,132
#2: Jul 15 '09

re: How i can have a .htaccess like twitter.com?


Quote:

Originally Posted by Lagon666 View Post

Hi

I wanna have a htaccess file that when i go to "www.domain.com/sometext" the page redirect to "www.domain.com/user.php?user=sometext". It's important that is better that URL not end with slash. I have a problem with my htaccess file:

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2. RewriteRule ^(.+)$ user.php?user=$1 [L,R]
But when i go to to "http://localhost/jack" the page will redirect to "http://localhost/user.php?user=user.php".

I have read this topic, but is it possible that "user" phrase doesnt exists after "^" character?

Remove the 'R' from your flags ([L, R] -> [L]).
Reply

Tags
apache, htaccess, twitter


Similar Apache Web Server bytes