Old link structure to new url structure - .htaccess

We have our own CMS, and having some vacancies website's. Now the issue is, for SEO we've changed the page, where the vacacies are showed on, now google says 300 vacancies can't be found.
I'm asking for your help, since i dont want to changes 300 urls handy..
What i have here is the next url :
website.html/vacatures/vacancieitem/289-docent-duits-1e-graad.html
website.html/vacatures/vacancieitem/245-docent-wiskunde-1e-graad.html
Needs to go to the new url
website.html/onderwijsvacatures/vacancieitem/289-docent-duits-1e-graad.html
website.html/onderwijsvacatures/onderwijsvacatures/245-docent-wiskunde-1e-graad.html
and so go onn

You can use the following redirect in your htaccess :
Redirect 301 /vacatures/ /onderwijsvacatures/

Related

Redirect issues: New category/article structure / How to get rid of the article id?

I guess, this is an easy one but anyway, I haven't figured it out yet.
After migrating my website from Joomla 3 to Joomla 4 the structure of categories and articles will change. That's why I will need some rules in .htaccess to redirect the old urls to the new ones.
The website is hosted on an Apache server.
The old URL structure looks something like that.
https://www.mydomain.de/category/subcategory/item/[articleID]-[articleAlias].html
[articleID] is a digit.
[articleAlias], e.g. „this-is-article-number-233“
This should be redirected to...
https://www.mydomain.de/newcategory/newsubcategory/[articleAlias].html
An example:
https://www.mydomain.de/category/subcategory/item/2324-this-is-my-latest-article.html
… should be redirected to...
https://www.mydomain.de/newcategory/newsubcategory/this-is-my-latest-article.html
I've played around with RedirectMatch and Rewrite Rule but haven't been successful to make it work. How do I get rid of the article id?
My latest try failed with...
RedirectMatch ^category/subcategory/item/([0-9]+)-(.*)$ /newcategory/newsubcategory/$1
Is there a simple and elegant solution to this? Thanks in advance!
UPDATE
Maybe it's more complex than I thought it was.
Main problem is that not only my categories changed but also the ids of the articles.
So, to stick with my example...
https://www.mydomain.de/category/subcategory/item/2324-this-is-my-latest-article.html
first turns into something like:
https://www.mydomain.de/newcategory/newsubcategory/1223-this-is-my-latest-article.html
Anyway, Joomla 4 is able to drop the article id automatically (guess with an internal rewrite) for seo-friendly URLs. I activated that feature to make the new URLs look like
https://www.mydomain.de/newcategory/newsubcategory/[articleAlias].html
The [articleAlias] stays the same.
A redirection according to what you actually ask should be possible like that:
RewriteEngine on
RedirectRule ^/?category/subcategory/item/[0-9]+-(.*)\.html$ /newcategory/newsubcategory/$1.html [R,L]
However I doubt that this really is what you want: this completely drops the numeric ID of the resource. Which means that it won't be available for processing when the redirected request comes back requesting the new, stripped URL. How do you want to internally rewrite that request back to the internal resource then, without that ID?
I made some more tests and it this is the final solution to my problem:
RedirectMatch 301 ^/?category/subcategory/item/[0-9]+-(.*)\.html$ /newcategory/newsubcategory/$1.html

Redirecting using wildcard

First question in here, so be gentle with me:)
Much easier to explain with examples of the url.
This is one of the current url's
domainname.com/loc/window-repair/england/
We now need to lose the /loc/ part of the url so that it would now point to
www.domainname.com/window-repair/england/
The problem is that it isnt just one url, there are approxcimately 1000 urls pointing to various destinations in the UK all with the loc part in the url, and they all have sub directories.
eg
domainname.com/loc/window-repair/england/north-east/darlington
or
domainname.com/loc/window-repair/england/north-east/
or
domainname.com/loc/window-repair/scotland/
How can I put in a redirect so that the link still works but without the loc part.
Many Thanks
Try this in your htaccess file:
RedirectMatch 301 ^/([^/-]+)-([^/-]+)/(.*)/?$ /loc/$1-$2/$3

Redesigned website: New URL structure: 301 Redirecting all old URLs

I have about 5500 indexed URLs in Google on my website and will soon launch a redesigned version of it with a brand new URL structure.
Because of thousands of backlinks I want to redirect all my old urls to the new ones using htaccess 301 redirect.
The problem is, it takes forever to manually write the htaccess-rules in Excel because I have to match all the new urls with the old ones.
I.e. this is how my Excel document would be set up:
| Old url | New url | htaccess rule |
/default/category/product-id/my-product | /category/my-product/ | 301 redirect /default/category/product-id/my-product http://mydomain.com/category/my-product/
Is there any way (software/service/tool) to match these urls based on the product name inside of the url so I don't have to do all this manually???
There are two ways I can think of:
you can use a HTTP Module which reads the excel and loads in to key-value pair as old and new URL and put it in cache. Then in the BeginRequest, if the URL (old url) is found in the key, do response.redirect to new page. You can add 301 header here which will make sure the browser gets message that this is permanently redirected.
Check CodeProject Article
If all your old and new url has got some pattern you can your IIS ReWrite module and use RegEx to create rule for the redirect.
Check IIS ReWrite Module
Hope that helps.
Milind
Assuming your old URLs are all in the format /default/category/product-id/my-product, then you can use formulas to get the next 2 cells
in B1, the new URL is construncted using /category/ and the text after the 4th/`:
="/category/"&MID(A1,FIND("/",A1,FIND("/",A1,FIND("/",A1,2)+1)+1)+1,99)&"/"
in C1, we can use those 2 values to construct the new redirect:
="301 redirect "&A1&" http://mydomain.com"&B1

.htaccess redirect pagination

At present my url structure of page is like this
Mysite.com/page-2
mysite.com/categoryname/page-2
I want to change it to
mysite.com/page/2/
mysite.com/category/categoryname/page/2/
Note that, I have multiple page, i.e. let's say a category have 100 page so I need to redirect all the earlier page number to the new url structure. Writing code of every url will be too tedious. I am not sure but using $ in the code can help.
Please let me know how can it be done via .htacess.
Thanks in advance.
Your URL structure is already with the desired one you have as I can see.
/category/telecom-news/page/2

How to erase part of the link using .htaccess

i change the permalink of wordpress with the rule "/%postname%/" and it's working perfectly.
The only problem i use wp-commerce and for some reason generate the permalink to the product with this in the end "&negozio=NEGOZIO" and so give for every product i want to see a 404 page.
I know with .htaccess you can rewrite urls so i'm asking what's the correct rule for make a link like this :
http://www.ctssolutions.it/products-page/gestione-banconote/bj-140/&negozio=NEGOZIO
became something like this :
http://www.ctssolutions.it/products-page/gestione-banconote/bj-140/
Thank in advance

Resources