Skip to main content
replaced http://webmasters.stackexchange.com/ with https://webmasters.stackexchange.com/
Source Link

I have a WordPress website hosted on Bluehost which contains the following URL pattern:

http://www.example.com/2017/01/30/sample-post/

I wanted to permanent redirect it to use this:

http://www.example.com/sample-post/

So I opened .htaccess kept in the example.com folder and changed it to the following with the help of a suggestion by w3dksuggestion by w3dk.

RewriteEngine On
RewriteRule ^\d{4}/\d\d/\d\d/(.+) /$1 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

After I wrote this rewrite rule, everything of the URL format example.com/2017/01/30/sample-post works great. However, there are a few URLs in the website that have the format example.com/name-of-category/2008/10/20/sample-post and are throwing a 404 as the result of the above rewrite rule.

I want to permanently redirect www.example.com/name-of-category/2008/10/20/sample-post to www.example.com/name-of-category/sample-post.

What change do I need to make in my .htaccess file?

I have a WordPress website hosted on Bluehost which contains the following URL pattern:

http://www.example.com/2017/01/30/sample-post/

I wanted to permanent redirect it to use this:

http://www.example.com/sample-post/

So I opened .htaccess kept in the example.com folder and changed it to the following with the help of a suggestion by w3dk.

RewriteEngine On
RewriteRule ^\d{4}/\d\d/\d\d/(.+) /$1 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

After I wrote this rewrite rule, everything of the URL format example.com/2017/01/30/sample-post works great. However, there are a few URLs in the website that have the format example.com/name-of-category/2008/10/20/sample-post and are throwing a 404 as the result of the above rewrite rule.

I want to permanently redirect www.example.com/name-of-category/2008/10/20/sample-post to www.example.com/name-of-category/sample-post.

What change do I need to make in my .htaccess file?

I have a WordPress website hosted on Bluehost which contains the following URL pattern:

http://www.example.com/2017/01/30/sample-post/

I wanted to permanent redirect it to use this:

http://www.example.com/sample-post/

So I opened .htaccess kept in the example.com folder and changed it to the following with the help of a suggestion by w3dk.

RewriteEngine On
RewriteRule ^\d{4}/\d\d/\d\d/(.+) /$1 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

After I wrote this rewrite rule, everything of the URL format example.com/2017/01/30/sample-post works great. However, there are a few URLs in the website that have the format example.com/name-of-category/2008/10/20/sample-post and are throwing a 404 as the result of the above rewrite rule.

I want to permanently redirect www.example.com/name-of-category/2008/10/20/sample-post to www.example.com/name-of-category/sample-post.

What change do I need to make in my .htaccess file?

edited tags
Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90
Tweeted twitter.com/StackWebmasters/status/840124610712555522
Formatting. Exemplified domain name according to meta. (Please use "example.com")
Source Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

I have a WordpressWordPress website hosted on Bluehost which contains the following URL pattern:

http://www.somewebsiteexample.com/2017/01/30/sample-post/

I wanted to permanent redirect it to use this:

http://www.somewebsiteexample.com/sample-post/

So I opened .htaccess.htaccess kept in the somewebsite.comexample.com folder and changed it to the following with the help of a suggestion by w3dksuggestion by w3dk.

RewriteEngine On
RewriteRule ^\d{4}/\d\d/\d\d/(.+) /$1 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

After I wrote this rewrite rule, everything of the urlURL format somewebsite.com/2017/01/30/sample-postexample.com/2017/01/30/sample-post works great. However, there are a few urlsURLs in the website that have the format somewebsiteexample.com/name-of-category/2008/10/20/sample-post and are throwing a 404 as the result of the above rewrite rule.

I want to permanentpermanently redirect www.somewebsiteexample.com/name-of-category/2008/10/20/sample-post to www.somewebsiteexample.com/name-of-category/sample-post.

What change do iI need to make in my htaccess.htaccess file?

I have a Wordpress website hosted on Bluehost which contains the following URL pattern:

http://www.somewebsite.com/2017/01/30/sample-post/

I wanted to permanent redirect it to use this:

http://www.somewebsite.com/sample-post/

So I opened .htaccess kept in the somewebsite.com folder and changed it to the following with the help of a suggestion by w3dk.

RewriteEngine On
RewriteRule ^\d{4}/\d\d/\d\d/(.+) /$1 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

After I wrote this rewrite rule, everything of the url format somewebsite.com/2017/01/30/sample-post works great. However there are a few urls in the website that have the format somewebsite.com/name-of-category/2008/10/20/sample-post and are throwing a 404 as the result of the above rewrite rule.

I want to permanent redirect www.somewebsite.com/name-of-category/2008/10/20/sample-post to www.somewebsite.com/name-of-category/sample-post.

What change do i need to make in my htaccess?

I have a WordPress website hosted on Bluehost which contains the following URL pattern:

http://www.example.com/2017/01/30/sample-post/

I wanted to permanent redirect it to use this:

http://www.example.com/sample-post/

So I opened .htaccess kept in the example.com folder and changed it to the following with the help of a suggestion by w3dk.

RewriteEngine On
RewriteRule ^\d{4}/\d\d/\d\d/(.+) /$1 [R=301,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

After I wrote this rewrite rule, everything of the URL format example.com/2017/01/30/sample-post works great. However, there are a few URLs in the website that have the format example.com/name-of-category/2008/10/20/sample-post and are throwing a 404 as the result of the above rewrite rule.

I want to permanently redirect www.example.com/name-of-category/2008/10/20/sample-post to www.example.com/name-of-category/sample-post.

What change do I need to make in my .htaccess file?

Source Link
Loading