.htaccesshttp-redirect

I need redirect /item/x to /item/y in .htaccess


I have rules in .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^item/(.*)/?$ item.php/$1 [L,NC]
RewriteRule ^([^\.]+)$ $1.php [L,NC]

Which redirects to /item/page

I removed one item from the store and now I need redirect /item/x to /item/y

Tried to redirect this way but it doesn't work

Redirect ^/item/x$ /item/y
Redirect https://testsite.org/item/x https://testsite.org/item/y
Redirect /item/x https://testsite.org/item/y

Solution

  • Why would you suddenly want to use a different module than the one you implemented your previous rules in? Why not stick with the rule you already know and implement another rule based on the rewriting module? So as a RewriteRule?

    RewriteEngine On
    RewriteRule ^item/x$ item/y [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^item/(.*)/?$ item.php/$1 [L,NC]
    RewriteRule ^([^\.]+)$ $1.php [L,NC]