301 redirect - requestion
7 posts
• Page 1 of 1
301 redirect - requestion
Hi,
We in our web site have category page and url will be like below
http://www.websiteurl.com/category.aspx?c=vegetables
After that we added helicon 3.0 software then we added below code in .htaaccess file.
RewriteRule /([^/]*)/c/([^/]*)/ /Category\.aspx\?c=$2 [I]
RewriteRule /([^/]*)/c/([^/]*)/([^/]*)/ /Category\.aspx\?c=$2 [I]
RewriteRule /([^/]*)/c/([^/]*)/([^/]*)/([^/]*)/ /Category\.aspx\?c=$2&$3=$4 [I]
Now we were able to use friendly url like below
http://www.websiteurl.com/vegetables/c/vegetables/
http://www.websiteurl.com/fruits/c/fruits/
This is working fine without any issue, but now I am not able to do the 301 redirects for vegetables category to vegetables-new category.
I tried below and it is not working.
RewriteRule /category.aspx?c= vegetables /vegetablesnew/c/vegetablesnew/ [L,R=301]
RewriteRule /vegetables/c/vegetables/ /vegetablesnew/c/vegetablesnew/ [L,R=301]
Do you have any suggestion?
Chinna.
We in our web site have category page and url will be like below
http://www.websiteurl.com/category.aspx?c=vegetables
After that we added helicon 3.0 software then we added below code in .htaaccess file.
RewriteRule /([^/]*)/c/([^/]*)/ /Category\.aspx\?c=$2 [I]
RewriteRule /([^/]*)/c/([^/]*)/([^/]*)/ /Category\.aspx\?c=$2 [I]
RewriteRule /([^/]*)/c/([^/]*)/([^/]*)/([^/]*)/ /Category\.aspx\?c=$2&$3=$4 [I]
Now we were able to use friendly url like below
http://www.websiteurl.com/vegetables/c/vegetables/
http://www.websiteurl.com/fruits/c/fruits/
This is working fine without any issue, but now I am not able to do the 301 redirects for vegetables category to vegetables-new category.
I tried below and it is not working.
RewriteRule /category.aspx?c= vegetables /vegetablesnew/c/vegetablesnew/ [L,R=301]
RewriteRule /vegetables/c/vegetables/ /vegetablesnew/c/vegetablesnew/ [L,R=301]
Do you have any suggestion?
Chinna.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: 301 redirect - requestion
Hello,
We'd suggest using the following:
Regards
Andrew
We'd suggest using the following:
- Code: Select all
RewriteCond %{QUERY_STRING} ^c=([^&]+)$ [NC]
RewriteRule ^[^/.]+\.aspx$ /%1/c/%1/? [NC,R=301,L]
Regards
Andrew
Re: 301 redirect - requestion
Andrew,
I added below code in my .htaaccess file
RewriteCond %{QUERY_STRING} ^c=([^&]+)$ [NC]
RewriteRule ^[^/.]+\.aspx$ /%1/c/%1/? [NC,R=301,L]
RewriteRule /category.aspx?c=vegetables /vegetablesnew/c/vegetablesnew/ [L,R=301]
RewriteRule /vegetables/c/vegetables/ /vegetablesnew/c/vegetablesnew/ [L,R=301]
Now this url "/category.aspx?c=vegetables" is redirecting to this url "vegetablesnew/c/vegetablesnew/"
But this url "/vegetables/c/vegetables/" is not redirecting.
How do I redirect one friendly url to another friendly url?
Chinna.
I added below code in my .htaaccess file
RewriteCond %{QUERY_STRING} ^c=([^&]+)$ [NC]
RewriteRule ^[^/.]+\.aspx$ /%1/c/%1/? [NC,R=301,L]
RewriteRule /category.aspx?c=vegetables /vegetablesnew/c/vegetablesnew/ [L,R=301]
RewriteRule /vegetables/c/vegetables/ /vegetablesnew/c/vegetablesnew/ [L,R=301]
Now this url "/category.aspx?c=vegetables" is redirecting to this url "vegetablesnew/c/vegetablesnew/"
But this url "/vegetables/c/vegetables/" is not redirecting.
How do I redirect one friendly url to another friendly url?
Chinna.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: 301 redirect - requestion
Hm... is there a patter for redirects from one friendly URL to another?
Do we really need the middle stage?
Regards
Do we really need the middle stage?
Regards
Re: 301 redirect - requestion
Won't the earlier rule cause /vegetables/c/vegetables to be rewritten to category.aspx?c=vegetables?
So the 301 rule won't be hit with the right URL to trigger.
You'd need to put the 301 rules *before* the existing rewrites.
So the 301 rule won't be hit with the right URL to trigger.
You'd need to put the 301 rules *before* the existing rewrites.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: 301 redirect - requestion
I agree with ChickPea, we need to take the order of the rules into the account.
Regards
Regards
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: 301 redirect - requestion
I agree with ChickPea, we need to take the order of the rules into the account.
Regards
Regards
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests