.htaccess redirection question

Discussion in 'PHP' started by infomalaya, Apr 4, 2009.

  1. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you do that, you will lost the ability to have any other URLs at that domain name (at least without extreme performance penalty). Are you sure it's what you want to do? Normally people use something like http://madridbarca.com/users/miccy/ so they they preserve the ability to have, for example, http://www.madridbarca.com/about
     
    SmallPotatoes, Apr 4, 2009 IP
  2. icooo

    icooo Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I agree with SmallPotatoes, you can do it with a .htaccess file like this:

    
    <IfModule mod_rewrite.c>
    	Options +FollowSymlinks
    	RewriteEngine on
    
    	#allow linking to existing files
    	RewriteCond %{REQUEST_FILENAME} -f [OR]
    	RewriteCond %{REQUEST_FILENAME} -d
    	RewriteRule ^.* - [L]
    	
    	#profile urls
    	RewriteRule ^Profile/(.*)$ profile.php?user=$1 [NC,L]
    </IfModule>
    
    Code (markup):
     
    icooo, Apr 4, 2009 IP
  3. infomalaya

    infomalaya Banned

    Messages:
    103
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think all social network use url like /miccy , i think i will stay that way

    Thanks, actually i got a similar code in my .htaccess what i want to do is when i click at /profile.php?user=miccy then it will redirect to /miccy , is it possible? thanks!

    here's my full htaccess code:
    RewriteEngine On
    Options +Followsymlinks
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.* - [L,QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^.*/images/(.*)$ /images/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^.*/uploads_user/(.*)$ /uploads_user/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/?$ /profile.php?user=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/([^/]+)?$ /profile.php?user=$1$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/classifieds/([0-9]+)/?$ /classified.php?user=$1&classified_id=$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/classifieds/([0-9]+)/([^/]+)?$ /classified.php?user=$1&classified_id=$2$3 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/classifieds/?$ /classifieds.php?user=$1 [L]
    
    RewriteCond %{HTTP_HOST} ^madridbarca.com [NC]
    RewriteRule ^(.*)$ http://www.madridbarca.com/$1 [L,R=301]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/polls/([0-9]+)/?$ /poll.php?user=$1&poll_id=$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/polls/([0-9]+)/([^/]+)?$ /poll.php?user=$1&poll_id=$2$3 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/polls/?$ /polls.php?user=$1 [L]
    
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*/)?event/([0-9]+)/([^/]*)$ /event.php?event_id=$1$2$3 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*/)?event/([0-9]+)/album/([0-9]+)/([^/]*)$ /event_album_file.php?event_id=$2&eventmedia_id=$3$4 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/albums/([0-9]+)/([0-9]+)/?$ /album_file.php?user=$1&album_id=$2&media_id=$3 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/albums/([0-9]+)/?$ /album.php?user=$1&album_id=$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/albums/([0-9]+)/([^/]+)?$ /album.php?user=$1&album_id=$2$3 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/albums/?$ /albums.php?user=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/blog/([0-9]+)/?$ /blog.php?user=$1&blogentry_id=$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/blog/([^/]+)?$ /blog.php?user=$1$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/blog/?$ /blog.php?user=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/trackback/([0-9]+)/?$ /blog_ajax.php?task=trackback&user=$1&blogentry_id=$2 [L]
    
    Code (markup):
     
    infomalaya, Apr 5, 2009 IP
  4. infomalaya

    infomalaya Banned

    Messages:
    103
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    anyone? really desperado here
     
    infomalaya, Apr 6, 2009 IP