我的网站过去常常有很多公司列表:
www.example.com/Directory <!-- old directory homepage
www.example.com/Directory/viewprofile.php?id=1599&company=test+company
我现在改变了整个CMS。新配置文件现在如下:
www.example.com/directory <!-- directory homepage
www.example.com/listing/listing/rennicks-mts/ <!-- individual listing page
1。我只是想知道我的301重定向是否适合这种新设置。
Redirect 301 ^/Directory http://www.highwaysindustry.com/directory/
另外,我的重定向是否意味着先包装好?整个过程如下:
# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
# END W3TC Browser Cache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?uploads/wpjobboard/application/(.+) /wp-content/plugins/wpjobboard/restrict.php?url=application/$2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Redirect 301 ^/Directory http://www.newwebsite.com/directory/
Redirect 301 /About-Us http://www.newwebsite.com/about
Redirect 301 /Uploads http://www.newwebsite.com/
Redirect 301 /News/?page=1 http://www.newwebsite.com/
Redirect 301 /News/?page=2 http://www.newwebsite.com/
Redirect 301 /News/?page=3 http://www.newwebsite.com/
Redirect 301 /News/?page=4 http://www.newwebsite.com/
Redirect 301 /News/?page=5 http://www.newwebsite.com/
Redirect 301 /News/?page=6 http://www.newwebsite.com/
2。如果它们被包装在任何其他标签中,我的所有重定向都会立即启动吗?
** CMS更改后域名相同。没有改变域名。
答案 0 :(得分:0)
在这种情况下,您不能将Redirect
指令与mod_rewrite规则一起使用。这是因为Redirect
是mod_alias的一部分,mod_alias在应用mod_rewrite之前应用,两者将应用于每个请求。因此,您最终会得到一些奇怪的结果。此外,您无法与?page=
中的查询字符串(例如Redirect
内容)进行匹配,您需要在条件中使用%{QUERY_STRING}
变量。
尝试这样的事情:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^Directory http://www.newwebsite.com/directory/ [L,R=301]
RewriteRule ^About-Us http://www.newwebsite.com/about [L,R=301]
RewriteRule ^Uploads http://www.newwebsite.com/ [L,R=301]
RewriteCond %{QUERY_STRING} ^page=[1-6]$
RewriteRule ^News/$ http://www.newwebsite.com/ [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?uploads/wpjobboard/application/(.+) /wp-content/plugins/wpjobboard/restrict.php?url=application/$2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
最后摆脱所有Redirect
指令