[英].htaccess rewriterule and 301 redirect
Good day. 美好的一天。 At the moment I am busy remodeling the website. 目前,我正在忙于改建网站。 Can't solve several problems. 无法解决几个问题。
1.I need to change the url structure - for example a link to «somepage» like: 1.我需要更改url结构-例如,类似于«somepage»的链接:
site.com/index.php?page=somepage
now will look like: 现在看起来像:
site.com/someCategory/somepage
As I understand in order not to lose page rank of «somepage» I need to do a 301 redirect. 据我了解,为了不丢失«somepage»的页面排名,我需要执行301重定向。 As I understand it will look like this: 据我了解,它看起来像这样:
Redirect 301 site.com/index.php?page=somepage site.com/someCategory/somepage
If more than one page (approximately 400) then it will look like this: 如果一页以上(大约400页),则它将如下所示:
Redirect 301 site.com/index.php?page=somepage site.com/someCategory/somepage
Redirect 301 site.com/index.php?page=somepage1 site.com/someCategory/somepage1
Redirect 301 site.com/index.php?page=somepage2 site.com/someCategory/somepage2
Redirect 301 site.com/index.php?page=somepageN site.com/someCategory/somepageN
2.I need to make a redirect from www to non-www. 2.我需要从www重定向到非www。 It will look like this: 它看起来像这样:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
3.Also, currently my .htaccess file has rules to create pretty URLs: 3.此外,目前我的.htaccess文件具有创建漂亮网址的规则:
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/(.+)/?$ index.php?category=$1&page=$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/?$ index.php?category=$1
The questions are: 问题是:
RewriteEngine On
# www to non-www
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
# SEO format to dynamic format (200, not 301)
RewriteRule ^someCategory/([^/]+)/?$ /index.php?page=$1 [QSA]
# 'someCategory' is fixed text
Is someCategory going to vary? someCategory会有所不同吗? Would it be useful to make it another Query String variable? 使其成为另一个查询字符串变量是否有用?
How does #3 differ from #1? #3与#1有何不同? You don't do a 301 mapping SEO format to internal dynamic format. 您无需执行301将SEO格式映射为内部动态格式的操作。 Is #3 more SEO-to-dynamic? #3是否更适合动态搜索引擎优化? How do you tell apart #1 and #3? 您如何区分#1和#3?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.