Hemantwagh07
Hemantwagh07

Reputation: 1556

Redirect article to 301 from directory redirected to 410

I have redirected directory to 410 in .htaccess

Redirect 410 /books/videos/

Now I want to write a rule to redirect some articles from /books/videos/ to 301 page. I tried it as follows

RewriteRule ^(.*)/books/videos/how-to-find-videos.html /books/how-to-find-videos.html [L,R=301]

When I visit www.mysite.com/books/videos/how-to-find-videos.html it shows me 410 gone page. That means 301 rule is not getting applied here. How can I achive 410 and 301 for same directory.

Thanks in advance.

Upvotes: 1

Views: 116

Answers (1)

anubhava
anubhava

Reputation: 784898

Don't mix Redirect and RewriteRule directives that are from different Apache modules.

Have it like this in given order:

RewriteEngine On

# specific files are redirected with 301
RewriteRule ^/?books/videos/how-to-find-videos\.html$ /books/how-to-find-videos.html [L,R=301,NC]

# remaining URIs from this path to get 410
RewriteRule ^/?books/videos/ - [L,R=410]

Make sure to clear your browser cache before testing this.

Upvotes: 1

Related Questions