htaccess的搜索引擎友好的URL - 重定向页面 [英] .htaccess SEO friendly URLs - redirect to page
本文介绍了htaccess的搜索引擎友好的URL - 重定向页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在看的.htaccess文件,现在我的网站重定向所有链接到搜索引擎友好的链接
例如
http://example.com/index.php?page=1到
http://example.com/home/1/
通过以下code
重写规则^家居/([0-9] +)/ $的index.php?网页= $ 1 [NC,L]
但是当我到了页
http://www.example.com/home/
我得到一个404错误....
我怎样才能得到它,这样,当/家庭/访问它会自动重定向到/ home / 1 /
解决方案
尝试使用:
重写规则^家/?$ http://www.yourdomain.com/home/1 [R = 301,L]
重写规则^家居/([0-9] +)/ $的index.php?网页= $ 1 [NC,L]
R = 301意味着重定向根据 HTTP状态code 是永久的P>
i am looking at .htaccess files and have my site now redirect all links to SEO friendly links
e.g
http://example.com/index.php?page=1 to
http://example.com/home/1/
by using the following code
RewriteRule ^home/([0-9]+)/?$ index.php?page=$1 [NC,L]
but when i got to the page
http://www.example.com/home/
i get a 404 error....
How can i get it so that when /home/ is accessed it automatically redirects to /home/1/
解决方案
Try with:
RewriteRule ^home/?$ http://www.yourdomain.com/home/1 [R=301,L]
RewriteRule ^home/([0-9]+)/?$ index.php?page=$1 [NC,L]
R=301 means that redirect is permanent according to HTTP status code
这篇关于htaccess的搜索引擎友好的URL - 重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文