Pages: [1]
Author Topic: ถามตอบ mod rewrite การสร้าง subdomain เสมือน  (Read 3243 times)
0 Members and 1 Guest are viewing this topic.
คิมจองไซ
Newbie
*

SEO Score : 0
Posts: 4


View Profile WWW
« on: October 04, 2012, 12:33:15 PM »

คำถาม
i am working on a new website bud i want to create a nice looking url for my users. I don't know anything of htaccess and could not find my solution on google.

i need to link: user.mywebsite.com to>> mywebsite.com/users/user

and: user2.mywebsite.com/contact to>> mywebsite.com/users/user2/contact

some links may not be linked like: www.mywebsite.com may not link to mywebsite.com/users/www

is this able with htaccess? if yes can someone explain it to me?

Sander.

( sorry for my poor english )


ทางแก้

Code:
RewriteEngine On

# the request URI doesn't already start with /users/
RewriteCond %{REQUEST_URI} !^/users/

# host doesn't start with www
RewriteCond %{HTTP_HOST} !^www\.  [NC]

# host starts with something else
RewriteCond %{HTTP_HOST} ^([^\.]+)\.mywebsite\.com$  [NC]

# rewrite
RewriteRule ^(.*)$ /users/%1/$1  [L]

ที่มา http://stackoverflow.com/questions/8490184/htaccess-mod-rewrite-subdomain

ลองดูนะครับ ผมยังไม่เคยลองเหมือนกัน หุหุ  Lips Sealed
Logged


Pages: [1]
Print
Jump to: