簡體   English   中英

如何使用htaccess將用戶個人資料URL轉換為subDomain

[英]how can i convert my users profiles URL to subDomain with htaccess

如何使用htaccess將用戶個人資料URL轉換為subDomain

我嘗試在htaccess中使用此代碼,但無法正常工作

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(iemg\.net)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

像: http : //iemg.net/usersprofile.php?username=mohamedhttp://mohamed.iemg.net

首先,您必須捕獲域的用戶部分,然后在替換中使用它

RewriteCond %{HTTP_HOST} ^(.*)\.iemg\.net$ [NC]
RewriteRule ^ http://iemg.net/usersprofile.php?username=%1 [R,L]

當一切正常運行時,可以將R替換為R=301 切勿使用R=301測試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM