I have a simple wordpress page with some news. In root directory I’ve set .htaccess with rules:
RewriteBase /news/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news/index.php [L]
As you can see it’s set that if client requests a file or dir that doesn’t exist he’s redirected to /news/index.php.
Now, I would like to set that if he calls for non existing graphic file from /news/wp-content/uploads/ subdirectory he should get a custom graphic instead (let’s say /news/wp-content/uploads/noimage.png). For this I modified .htaccess:
RewriteBase /news/wp-content/upload/
RewriteCond %{REQUEST_FILENAME !-f
RewriteRule . /news/wp-content/upload/notFound.png
RewriteBase /news/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news/index.php [L]
But now when I try to load page (even index page) I get internal server error. What’s wrong here?
Your first rule is actually hijacking all the legit WP requests since those are never for a valid file. Replace your complete code with this:
if there is no .htaccess in wp-contnent directory:
if there is .htaccess in wp-contnent directory then use this code on top of
wp-contnent/.htaccess
file:Instead of fiddling with the RewriteBase, why don’t you try this: