我有一个网站说' 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
请帮帮我。
答案 0 :(得分:1)
在DocumentRoot
的{{1}}内,使用以下代码创建名为www.alpha.example.com
的文件:
.htaccess
答案 1 :(得分:1)
我会这样做是为了完整。这样,如果他们输入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]