TutorialLab
TutorialLab

Reputation: 1

.htaccess issue for 301 redirect url

I want to use 301 redirects for my website URLs. The URL redirects to the wrong path and the website give me a 404 error. When I use this redirect.

Redirect 301 /couponstore/evitamins-120 https://website.com/codes/evitamins-coupon-codes

it gives me a result like this

https://website.com/codes/evitamins-coupon-codes?lcp=couponstore/evitamins-120

the lcp=couponstore/evitamins-120 is an extra part and it is injected to the URL due to the .htaccess rewrite. When I remove the last part of the rewrite rule ^((.*?)(\-(\d+))?)([.]\w+)?$ index.php?lcp=$1&lcp_id=$4&ext=$5 [QSA,L] then my website stop working and I am getting errors on all pages.

Below is the .htaccess code for my website:

<IfModule mod_rewrite.c>
## Turn on rewrite engine
RewriteEngine on
## Coupons CMS v7
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((.*?)(\-(\d+))?)([.]\w+)?$ index.php?lcp=$1&lcp_id=$4&ext=$5 [QSA,L]
</IfModule>

what should I do to use redirects for my website URLs, I lost all the SEO for my website due to this one issue which I am not capable to resolve, need suggestion/help to redirect old URLs to the new.

thank you.

Upvotes: 0

Views: 113

Answers (1)

RavinderSingh13
RavinderSingh13

Reputation: 133518

Based on your shown samples, could you please try following. Please make sure to clear your browser cache before testing your URLs.

<IfModule mod_rewrite.c>
## Turn on rewrite engine
RewriteEngine ON
## Coupons CMS v7

RewriteRule ^(couponstore/evitamins-120)/?$ codes/evitamins-coupon-codes [R=301,NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((.*?)(\-(\d+))?)([.]\w+)?$ index.php?lcp=$1&lcp_id=$4&ext=$5 [QSA,L]
</IfModule>

Upvotes: 1

Related Questions