Skip Navigation

[Gelöst] htaccess rewrite rule for custom types

This support ticket is created vor 6 Jahren, 11 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Dieses Thema enthält 5 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von jurgenK-2 vor 6 Jahren, 11 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#599500
Screenshot.JPG

I am trying to:
I have a wordpress site with about 7000 pages (custom posts) and the names of these pages will have a small change in the page title/url. You can see the full list here:
versteckter Link

The URL will change at the beginning of the title. The URL looks now like this:
versteckter Link
and will change for each item to
versteckter Link

The logic behind is:
versteckter Link
will change to
versteckter Link

To make sure that users will be redirected from the old link to the new link I want to implement a redirect rule in htaccess.

RewriteEngine On
RewriteRule ^friedhof/(.*)/$ versteckter Link [R=301,NC,L]

But this unfortunately interferes with the rewrite rules of Toolset itself.

I have a funny effect when I put this code in htaccess. the URL will be:
versteckter Link

The custom post has a custom slug "grabkosten" generated by Toolset -> see screenshot.

When I change the option in Toolset to "Rewrite -> Use the normal WordPress URL logic" the htaccess code works. in the normal WordPress URL logic the slug is called "Friedhof" (versteckter Link)

Have you got an idea how I can make sure that users will get from
versteckter Link
to
versteckter Link

Thanks a lot for your help!

Regards
Jürgen

#599626

Unfortunately I am no expert in -htaccess redirect rules.

I will need to ask a colleague about this on Monday, and I'll update you when I have some additional information.

Thank you for the patience.

#600290

Here's what seems to be working as a redirect for me:

RewriteCond "%{REQUEST_FILENAME}"   "!^grabkosten/grab-auf-"
RewriteRule ^grabkosten/(.*)/$ /grabkosten/grab-auf-$1 [R=301,NC,L]

You have to be sure "grab-auf-" is not already part of the URL, otherwise you'll get the "too many redirects" error. Once you add this redirect, create a new Friedhof post (do not use grab-auf- in the title) and test the permalink. It should redirect to the correct URL with grab-auf-, but it should show a 404 since nothing exists at that URL.

#600412

hm, that works exactly as you describe (great work), but it is not yet the solution I need.

I will manually change all titles to "grab auf-pagetitle", so we have the issue you describe. The redirect should only be for those items which do not have "grab-auf-" in their title.

I copied the site to a test server and manually changed the first item in this list as I want to change all items:
versteckter Link - First item:
Alter Friedhof
versteckter Link

This will lead to
versteckter Link

The point is the following. I want to add "grab" in the URL for SEO reasons. And I do not want to lose the position in Google ranking. So the old URL in search engine listings should redirect to the new URL, but within the site there are the new URL which should not be redirected again.

Is there a solution for this?

Would it make a difference to change the path to /grabkosten/grab-auf/alter-friedhof-rasengrab-wiese-anonym?
This could be another option. I like the other option more as it is more human readable but this could be ok, too.

Thanks a lot, regards,
Jürgen

#600619

Sorry, I'm not sure how to do fix this in either case with htaccess. Toolset's rewrite capabilities are limited to the slug of a CPT, but do not extend to further conditional manipulation. It appears that our best efforts were not much help here. Sorry I wish I could provide you some assistance to accomplish what you're looking for, but it's just not part of what Toolset is designed to do. It might be worthwhile to examine some redirect plugins to try to accomplish this for you.

#601228

Upps, the redirect is automatically...

I talked with my client, and he agreed to make the change without redirecting.

I changed the page title /slug and - voila - the pages are redirected automatically.

Just click here:
versteckter Link

Thanks for your help anyway.

Have a nice christmas time!

Regards,
Jürgen