2017-04-20 100 views
1

如果用户尝试访问包含“/ product /”的url的页面,我试图重定向到特定页面(存储页面)得到一个404错误。如果URL包含htaccess中的字符串,则重定向到特定的页面

这是我目前在我的htaccess:

重写规则^ /产品/.* /店[R = 404,L]

什么我需要改变,以得到这个工作?

这里我当前htaccess文件:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ www.mydomain.com/$1 [R=301,L] 

# Send surplus store 404 errors to the store home page 
ErrorDocument 404 /store 
RewriteEngine On 

RewriteRule ^/?product(/.*)?$ - [R=404,L,NC] 

# handle both specific URL redirects for woocommerce 
RewriteRule ^/?product-(?:tag|categories|category)/([\w-]+) www.mydomain.com/parts?category=$1 [R=301,L,NC,QSA] 

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 

RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR] 
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ 
RewriteRule ^MyAccount\.aspx\/?(.*)$ "http\:\/\/online\.mydomain\.com\/$1" [R=301,L] 

回答

1

您可以在网站根目录的.htaccess使用此代码:

# BEGIN WordPress 
RewriteEngine On 
RewriteBase/

# handle both specific URL redirects for woocommerce 
RewriteRule ^/?product-(?:tag|categories|category)/([\w-]+) www.mydomain.com/parts?category=$1 [R=301,L,NC,QSA,NE] 

RewriteCond %{HTTP_HOST} ^(?:www\.)?mydomain\.com$ [NC] 
RewriteRule ^MyAccount\.aspx(/.*)?$ http://online.mydomain.com$1 [R=301,L,NC,NE] 

# redirect /product URIs 
RewriteRule ^/?product(/.*)?$ /store [R=301,L,NC] 

RewriteRule ^index\.php$ - [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 

# END WordPress 
+0

谢谢你的答案,但它不工作对我这个网址WWW结束.mydomain.com/product/t414751r-exchdpf-filter – Aaron

+0

好吧,我已经更新了我的htaccess的问题,我不得不删除一些https:// – Aaron

+0

啊这是wordpress :(你必须做不同的主题404处理程序,并且可能是WP重写API – anubhava

相关问题