How to redirect if a page doesn't exist with Apache
Read OriginalThis article explains how to redirect non-existent root-level pages to an /articles subdirectory using Apache's mod_rewrite in .htaccess. The author moved 3,000 articles from the root to /articles and needed a bulk redirect solution without breaking existing pages. The provided RewriteRule checks if the request is not already for /articles, not an existing file or directory, then redirects to /articles/requested-path with a 301 status. Includes code snippet and explanation for preventing recursive redirects.
Comments
No comments yet
Be the first to share your thoughts!
Browser Extension
Get instant access to AllDevBlogs from your browser
Top of the Week
No top articles yet