Skip to content

Instantly share code, notes, and snippets.

@Maden-maxi
Last active March 24, 2017 10:23
Show Gist options
  • Save Maden-maxi/4745488f52a044a700191aaadee01c39 to your computer and use it in GitHub Desktop.
Save Maden-maxi/4745488f52a044a700191aaadee01c39 to your computer and use it in GitHub Desktop.
Redirect 301 with rexexp
Redirect 301 index\.php/[\d]{4}/[\d]{2}/[\d]{2}/(.*) http://%{HTTP_HOST}/$1
# -------------------
RewriteCond %{REQUEST_URI} (index\.php)/(\d{4})/(\d{2})/(\d{2})/(.*)
RewriteRule (index\.php)/(\d{4})/(\d{2})/(\d{2})/(.*) http://%{HTTP_HOST}/%5
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$4 [R=301,NC,L]
RewriteRule ^index\.php/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$4 [R=301,NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
#--------------
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$4 [R=301,NC,L]
RewriteRule ^index\.php/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ /$4 [R=301,NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# Redirect from old links
# Redirect 301 index\.php/[\d]{4}/[\d]{2}/[\d]{2}/(.*) http://%{HTTP_HOST}/$1
# Redirect 301 [\d]{4}/[\d]{2}/[\d]{2}/(.*) http://%{HTTP_HOST}/$1
# End Redirect from old links
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment