Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 05-10-2011, 12:07 PM
DigitalAlien's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 10-11-09
Posts: 2,283
iTrader: 0 / 0%
.htaccess help

I am trying to setup a very simple redirect in my .htaccess file and was hoping someone could help out.

If someone goes to

Code:
http://YourName.mywebsite.com
I want it to redirect to

Code:
http://www.mywebsite.com/User-YourName
Obviously, every user will have have a different username.

Can anyone post the code for this please?

Last edited by DigitalAlien; 05-10-2011 at 12:11 PM.
 
Reply With Quote
  #2 (permalink)  
Old 05-10-2011, 10:55 PM
nemrod's Avatar
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 461
iTrader: 0 / 0%
To redirect it visibly:
Code:
RewriteCond %{HTTP_HOST} ^YourName\.example.\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/User-YourName/$1 [R=301,L]
To redirect it "invisibly":
Code:
RewriteCond $1 !^User-YourName/ RewriteCond %{HTTP_HOST} ^YourName\.example\.com$ [NC] RewriteRule (.*) /User-YourName/$1 [L]
 
Reply With Quote
  #3 (permalink)  
Old 05-11-2011, 05:26 AM
DigitalAlien's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 10-11-09
Posts: 2,283
iTrader: 0 / 0%
That would work but "YourName" is always going to be a different username so I was hoping for some type of wildcard redirect so I don't have to create lines in the htaccess for every new member.
 
Reply With Quote
  #4 (permalink)  
Old 05-11-2011, 08:18 AM
Junior Member
 
Join Date: 05-10-11
Posts: 28
iTrader: 0 / 0%
make sure when using mod_rewrite to have this on your top line RewriteEngine on
 
Reply With Quote
  #5 (permalink)  
Old 05-12-2011, 07:10 AM
DigitalAlien's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 10-11-09
Posts: 2,283
iTrader: 0 / 0%
I already am.
 
Reply With Quote
  #6 (permalink)  
Old 05-14-2011, 01:33 AM
Contributing Member
Latest Blog:
None

 
Join Date: 05-14-11
Posts: 78
iTrader: 0 / 0%
What if your service provider is stupid and does not support .htaccess file nor php/asp?? Any ideas?

I believe the "primary site" configuration in google webmaster tools allows the backlinks to your non-www site to be counted towards your www site... that's what I have at this point but I'd love to find a way to do the virtual redirect as well...
 
Reply With Quote
  #7 (permalink)  
Old 05-14-2011, 02:31 AM
Contributing Member
Latest Blog:
None

 
Join Date: 05-06-11
Location: Opus
Posts: 70
iTrader: 0 / 0%
Quote:
Originally Posted by JackRT View Post
What if your service provider is stupid and does not support .htaccess file nor php/asp?? Any ideas?
I wonder if any paid hosting will do like that foolishness. Even many free hostings also offer PHP & ASP.
 
Reply With Quote
  #8 (permalink)  
Old 05-14-2011, 02:35 AM
Contributing Member
Latest Blog:
None

 
Join Date: 05-14-11
Posts: 78
iTrader: 0 / 0%
LOL.... freakin Homestead does this... though I like the fact that their customer service is US based... they don't outsource jobs, I ignore small things like this...
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conflict, What is the right htaccess rule, default homepage file with htaccess? basketmen Coding Forum 2 01-20-2009 07:50 AM
.htaccess help wongpk Coding Forum 7 04-04-2006 07:53 AM
htaccess help kwvarga Coding Forum 8 03-21-2006 04:42 AM
What can you do with .htaccess? Jason Web Design Lobby 4 12-03-2004 10:39 PM
.htaccess Pimpen 2010 Coding Forum 15 10-21-2003 01:39 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 06:09 AM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.