I have an issue that when I add a simple line to the .htaccess file it immediately gives me an internal server error. I have no idead what is wrong, the current content of the .htaccess file is the following:
# 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
If I add a line and get the .htaccess file looking like below, it immediately breaks the site and gives me 500 Internal server error:
# 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
#Begin security
<files wp-config.php>
order allow,deny
deny from all
</files>
Could you kindly let me know what I can check in order to stop this from happening?
Another thing which I also noticed is that if I add a security plugin through wordpress, and start enabling things, it also breaks the site.
I have also looked in the error log when trying to load the site and the following is the error I get:
.htaccess: order not allowed here
I have fixed the issue, what I noticed is that the following configuration in my directory was blocking the .htaccess to work
AllowOverride FileInfo Options
Changed it to the following and everything
AllowOverride All
Related
See below, the .htacess file from Wordpress. If I remove the part starting from # BEGIN WordPress, all the image file URLs will be changed to d28rt1vkpsdxas.cloudfront.net/someimage.png successfully.
However, all the internal links will be unable to access (only the home page can access). The error is
Not Found The requested URL /shop/ was not found on this server.
But if I keep the part start from # BEGIN WordPress, the CDN redirect will not work anymore. All photos are missing.
Options +FollowSymlinks
RewriteEngine on
Rewriterule ^wp-content/uploads/(.*)$ http://exampled28t1vkps.cloudfront.net/$1 [r=301,nc]
# 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
You’re missing the [L] flag, which prevents other rules from redirecting:
Rewriterule ^wp-content/uploads/(.*)$ http://exampled28t1vkps.cloudfront.net/$1 [r=301,nc,l]
I'm trying to deny access to my WordPress site while it's under construction. I have denied all other IP which appears to work fine when I comment out WP part of htaccess. When WP part of htacess is present and I access from forbiden IP, index.php page gets displayed, just without css or images.
Can someone explain how it happens and how to prevent it?
Thanks!
# ALLOW USER BY IP
<Limit GET POST>
Require all denied
Require ip 93.112.174.
</Limit>
# 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
One answer from user got deleted so I can't mark it as solution... Thanks! :)
Using rewrite rules was most simple way to achieve what I wanted, works fine on latest stable Apache 2.4.18
<If "-R '93.112.0.0/16'">
# 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
</If>
<Else>
RewriteEngine On
RewriteRule ^ - [F]
</Else>
I've set up a Wordpress blog on Heroku using the great tips here - http://blog.pardner.com/2012/04/migrating-a-wordpress-blog-to-heroku/. Everything seems to be working fine with the default permalinks (http://www.mysite.com/blog/?p=123), but if I try to switch to permalinks that use the post name - I run into problems. It seems to work fine after switching the settings and saving them, but after a few hours (maybe when the temporary filesystem of Heroku goes away?), it stops working, and trying to access posts redirects me to my site's main page .
I implemented the changes to .htaccess as described in the above link , so my .htaccess file looks like this:
Options -Indexes
# 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
Fixed it. Since my blog was placed at http://www.mysite.com/blog/ and not at http://www.mysite.com/, the .htaacces file should look like this:
Options -Indexes
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
I have a wordpress hosting site www.mysite.com/myBlog . The wordpress installation is done inside public_html/www/myBlog folder inside my host folder.
I also have a folder public_html/www/myName which redirects me to a domain myName.com
Although this works fine but inside myName folder i have files like index.html. acad.html, worexp.html
clicking on them i expect a behavior like
myName.com/index.html
myName.com/acad.html
myName.com/workex.html
though i get it as myname.com only.
I found htaccess rules in myName folder as :
Redirect http://mydomainName.com/myName/+
# 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
RewriteCond %{HTTP_HOST} ^mydomainName.com$
RewriteRule ^/?$ "http\:\/\/www\.mydomainName\.com\/myBlog" [R=301,L]
Can anyone help me with whats wrong with the htaccess file ?
More details:
My WordPress blog has something messed up. I can go to my blog and homepage works fine but when i try to go to any post it throws an 403 error. Apache forbidden.
Tried talking to web host for permissions its ok.
checked htaccess. Replaced code by default code stil not working.
Removed permalinks to default deleted htaccess created new permalinks.
Gave permissions to all the files in blog directory
Rewrote robots.txt Blog url is : www.windowsvj.com
Wordpress community is not able to suggest something very helpful too.
Current Redirect rule code in .htaccess is :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wpblog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wpblog/index.php [L]
</IfModule>
# END WordPress
This could be the result of FollowSymLinks being disabled in the server configuration. Simply adding Options +FollowSymlinks to the .htaccess file could do the trick.
Instead of using the flag [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wpblog/
RewriteRule ^index\.php$ - [L] <---
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wpblog/index.php [L] <---
</IfModule>
# END WordPress
Try using [QSA]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wpblog/
RewriteRule ^index\.php$ - [QSA] <---
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wpblog/index.php [QSA] <---
</IfModule>
# END WordPress
How [L] works is if the RewriteRule matches
RewriteRule . /wpblog/index.php [L]
Then all other rewrites after this RewriteRule are ignored as stated on the Apache website
"In most contexts, this means that if the rule matches, no further rules will be processed." http://httpd.apache.org/docs/current/rewrite/flags.html
Here is a link with more information on .htaccess flags
http://httpd.apache.org/docs/current/rewrite/flags.html
Hope this works for you :P
I installed the wordpress 2.9.2 a few days ago and it works correctly. today , i want to use permlink feature of wordpress.
I know , must modify my .htaccess file on my site root. but on my sub-domain root there is no any .htaccess file . so i create my .htacess file with follow content on sub-domain root (near index.php file):
<files .htaccess>
order allow,deny
deny from all
</files>
ServerSignature Off
<files wp-config.php>
order allow,deny
deny from all
</files>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Options All -Indexes
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
But after save it , i missed my blog . And i get follow error :
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
after this i remove the .htaccess file , but this was not correct.
What i can do for it?
Cheers
I'm not sure what your other settings are there, but your rewrite block is correct. Try removing the rest of the contents of the file all together and see what happens. It may just be that you have more than you even need. Here is the entirety of my .htaccess for one of my WordPress installs with permalinks working correctly.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
- EDIT -
Also, that .htaccess is from a root domain that has sub-domains working accordingly without additional files or modification to the .htaccess.
Seems like a .htaccess file does not exist by default. But when you explicitly change the permalink structure by going to Settings->Permalinks in the WP admin area, a .htaccess file is automatically deleted. So, you may try to delete your current .htaccess file and then enable permalikns from admin area and .htaccess file will be automatically generated. First, my Wp install had no .htaccess file but when I altered the Permalink structure, here's what I got in my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I changed the .htaccess file with follow Content:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
But nothing happens and we have error again.
The amazing thing is: I removed the file, but the error is still there.