如何在子域中使 seo friedly url
How make seo friedly url in subdomain
我有一个网站说 ' www.example.com'
,我也在这个网站上创建了子域,说 'www.alpha.example.com'
。我需要将动态页面转换为 SEO 友好 URL。
我的 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= [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= [NC,L]
我有一个网站说 ' www.example.com'
,我也在这个网站上创建了子域,说 'www.alpha.example.com'
。我需要将动态页面转换为 SEO 友好 URL。
我的 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= [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= [NC,L]