[Edit: Apparently this was due to a caching issue on my end and a separate redirect happening on the site that was screwing up the RewriteEngine, or at least that's what it seems like.]
I'm trying to do what I thought was something simple and obvious with an .htaccess redirect, but getting behavior that confuses me despite having done similar things dozens of times, and I'm hoping someone can point me to what stupid mistake I'm making (or a better .htaccess tutorial than Google is giving me).
It's a site where there are some bad links pointing to index.shtml at the root of the site, when they should point to index.php, and a subdirectory, /blog/ containing a Wordpress installation.
At the root of the site, I created an .htaccess file with the following:
And then in the /blog/ directory is a Wordpress generated .htaccess with the following standard content:
I would expect this to redirect /index.shtml at the root of the site, only, to /index.php at the root of the site. However, trying to access /blog/ is also redirecting to /index.php at the root of the site, and I have no idea why. If I blank out the .htaccess file at the root, the /blog/ subdirectory resumes working as expected.
What am I not understanding about how "redirect 301" works?
I'm trying to do what I thought was something simple and obvious with an .htaccess redirect, but getting behavior that confuses me despite having done similar things dozens of times, and I'm hoping someone can point me to what stupid mistake I'm making (or a better .htaccess tutorial than Google is giving me).
It's a site where there are some bad links pointing to index.shtml at the root of the site, when they should point to index.php, and a subdirectory, /blog/ containing a Wordpress installation.
At the root of the site, I created an .htaccess file with the following:
Code:
redirect 301 /index.shtml http://site.com/index.php
And then in the /blog/ directory is a Wordpress generated .htaccess with the following standard content:
Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
I would expect this to redirect /index.shtml at the root of the site, only, to /index.php at the root of the site. However, trying to access /blog/ is also redirecting to /index.php at the root of the site, and I have no idea why. If I blank out the .htaccess file at the root, the /blog/ subdirectory resumes working as expected.
What am I not understanding about how "redirect 301" works?
Last edited: