PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 12, 2022

[FIXED] WordPress: Redirect Removing date from url using .htaccess

 March 12, 2022     .htaccess, apache, mod-rewrite, redirect, wordpress     No comments   

Issue

I have a redirect problem with WordPress and removing the date from the URL:

OLD:
https://www.example.de/2022/03/03/here-is-the-article-name-2582/

NEW:
https://www.example.de/here-is-the-article-name-2582/

Redirect ERROR:
https://www.example.de/03/

he redirect all the time on the "day" path.

here my .htaccess test:

########### REDIRECT 301 ############
RewriteEngine on
RewriteBase /

RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$3 [R=301,NC,L]
RewriteRule ^category(/.*|)$ /kategorie/$1 [R=301,L,NC]
RewriteRule ^tag(/.*|)$ /schlagwort/$1 [R=301,L,NC]

#RedirectMatch 301 /([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$4

########### ALTE URL mit DATUM - REDIRECT 301 - OHNE Datum ############
#<IfModule mod_rewrite.c>
#   RewriteEngine On
#   RewriteBase /
#   RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$3 [R=301,NC,L]
#</IfModule>

What can I do for the correct routing?


Solution

this redirect 301 works now for me:

########### REDIRECT 301 ############
RewriteEngine on
RewriteBase /

RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$4 [R=301,NC,L]
RewriteRule ^category(/.*|)$ /kategorie/$1 [R=301,L,NC]
RewriteRule ^tag(/.*|)$ /schlagwort/$1 [R=301,L,NC]


Answered By - Sebastian Schmal
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing