[英]How make seo friedly url in subdomain
我有一個名為' www.example.com'
的網站,我還在此站點中創建了一個子域名, 'www.alpha.example.com'
。 我需要將動態頁面轉換為SEO友好URL。 我的網址是'www.alpha.example.com/test/article.php?cat=people'
進入
'www.alpha.example.com/test/article/people'
如何使用.htacces
解決此問題
請幫我。
在www.alpha.example.com
DocumentRoot
內部,使用以下代碼創建一個名為.htaccess
的文件:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?alpha\.example\.com$ [NC]
RewriteRule ^test/article/([^/]+)/?$ test/article.php?cat=$1 [L,NC,QSA]
我會這樣做,以確保完整性。 這樣,如果他們輸入www.alpha.example.com/test/article.php?cat=people
那么它將同時重定向到www.alpha.example.com/test/article/people
因此您將同時獲得這兩種方式。
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?alpha\.example\.com$ [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /test/article\.php\?cat=([^&\ ]+)
RewriteRule .* /test/article/%1? [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?alpha\.example\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^test/article/([^/]+)/?$ /test/article.php?cat=$1 [NC,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.