Advertisement:

Author Topic: SOLVED htaccess redirect old category  (Read 1273 times)

andrei2987

  • Newbie
  • *
  • Posts: 40
SOLVED htaccess redirect old category
« on: July 26, 2017, 04:18:38 pm »
hi,

how can i redirect my old category to my new category with .htaccess?

https://mysite/oldcategory
to
https://mysite/newcategory

my .htaccess now is like this:

Code: [Select]
<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

thank you all
« Last Edit: July 27, 2017, 02:47:22 pm by andrei2987 »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: htaccess redirect old category
« Reply #1 on: July 26, 2017, 05:13:14 pm »
Code: [Select]
RewriteCond %{HTTP_HOST} ^(www.)?yoursite.com$
 RewriteRule ^oldcategory/(.*)$ https://yoursite.com/newcategory/$1 [R=301,L,QSA]

andrei2987

  • Newbie
  • *
  • Posts: 40
Re: htaccess redirect old category
« Reply #2 on: July 26, 2017, 05:25:55 pm »
Code: [Select]
RewriteCond %{HTTP_HOST} ^(www.)?yoursite.com$
 RewriteRule ^oldcategory/(.*)$ https://yoursite.com/newcategory/$1 [R=301,L,QSA]

hi marius,

thank you for reply

code is not working!

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: htaccess redirect old category
« Reply #3 on: July 26, 2017, 05:28:39 pm »
This is the way you used it?
I copied from my website and in my case it works fine.

Code: [Select]
<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{HTTP_HOST} ^(www.)?yoursite.com$
RewriteRule ^oldcategory/(.*)$ https://yoursite.com/newcategory/$1 [R=301,L,QSA]

</IfModule>

Ps.
Only that osclass gas the termination for categories "_id".
Ah no, only for items.
« Last Edit: July 26, 2017, 05:30:46 pm by marius-ciclistu »

andrei2987

  • Newbie
  • *
  • Posts: 40
Re: htaccess redirect old category
« Reply #4 on: July 26, 2017, 05:32:03 pm »
Yes, that's how I used it

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: htaccess redirect old category
« Reply #5 on: July 26, 2017, 05:34:45 pm »
...I don't know then... this is how I redirected a renamed subdomain.

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: htaccess redirect old category
« Reply #6 on: July 26, 2017, 06:21:42 pm »
Have you tried:

Code: [Select]
<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www.)?yoursite.com$
RewriteRule ^oldcategory/(.*)$ https://yoursite.com/newcategory/$1 [R=301,L,QSA]

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

?

andrei2987

  • Newbie
  • *
  • Posts: 40
Re: htaccess redirect old category
« Reply #7 on: July 26, 2017, 06:37:52 pm »
yes marius is work

I also found this solution

Code: [Select]
RewriteRule ^oldcat(/.*|)$ /newcat/$1 [R=301,L,NC]
use like this

Code: [Select]
<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /

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

RewriteRule ^oldcat(/.*|)$ /newcat/$1 [R=301,L,NC]

</IfModule>

I do not know what's the difference but it works with both

I think the first time was a cache issue

thank you marius for your time.

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: htaccess redirect old category
« Reply #8 on: July 26, 2017, 08:52:52 pm »
I'm glad to help:)

PS. My solution has a wildcard and redirects for example
site.com/category/item_i40 to
site.com/newcategory/item_i40
with that QSA.
« Last Edit: July 26, 2017, 08:59:24 pm by marius-ciclistu »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: htaccess redirect old category
« Reply #9 on: July 26, 2017, 10:59:48 pm »
You can mark this topic as SOLVED by modifying the first post's title.