Wordpress Options FollowSymLinks error - apache

I have a website setup in my /httpdocs directory with it's own htaccess and I have a wordpress blog within /httpdocs/blog, using the standard wordpress htaccess
I keep seeing the following error in my apache error log:
[error] [client #.#.#.#] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /var/www/vhosts/somedomain.com/httpdocs/blog/index.pl
I added "Options +FollowSymLinks" as this seems to have fixed the problem for others (but not me)
The main .htaccess is as follows:
The Wordpress .htaccess is:
Options +FollowSymLinks
# 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 WordPres
I am also wondering why the error is reported as "index.pl" since there are no perl scripts in /blog. So, after some searching, I found an httpd.include file (plesk generated) in the /var/www/vhosts/somedomain/conf/ which contains some perl handler stuff:
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
allow from all
PerlSendHeader On
If I remove perl support via Plesk, thus removing the above block of code, then I don't get errors anymore.
The obvious answer would be to disable perl as I don't need it, however there must be a way to fix this error without having to do that?

add to .htaccess
Options FollowSymLinks
all done :)

Related

.htaccess not working on SSL apache

Trying to fix this .htaccess, so it can work on a SSL apache server. Before it was hosted on another Linux server (http://) and was working without problems, but when uploading the files to another Linux server with apache and SSL (https://), it stopped working. The main function is to hide the .php extension...
HereĀ“s what I was using:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]
Thanks for your help!
So, .htaccess files may not be allowed, and by default on many systems they are not allowed. To see if .htaccess is allowed, make this your .htaccess:
BREAK IT!
That should be the only contents in your .htaccess. Attempt to load any page on your website, and if .htaccess usage is enabled, you would see "Internal Server Error" or possibly some other error, but you would not see your actual page.
If you do see the error, that's actually good and means .htaccess usage is enabled. If you don't see the error, it's likely that you will have to find your Apache .conf file and inside look for the line(s):
AllowOverride None
Change that to:
AllowOverride All
If after doing that you still can't use .htaccess, then there may be other apache related files that have "AllowOverride None". On that comes to mind is your virtual host file, and on my system that is located at /etc/apache2/sites-available/.
If you still have problems, check this out:
https://docs.bolt.cm/3.3/howto/making-sure-htaccess-works
Solution is for the issue, need to change in apache2.conf file after that it will works,
Change this file /etc/apache2/apache2.conf
update it same
OLD:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
New Updated Code:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I had a similar problem. Apache 2.4.23 with .htaccess error 404 set up.
Using it with HTTP works fine; access it with HTTPS didn't work.
I seted AllowOverride All in the http.conf and error 404 wors well.

mod_rewrite all to index.php in one environment

I know there are a million of questions about this, but I've tried the solutions in other questions and haven't got it to work in my case. I'm trying to redirect everything to index.php:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
This works in my local environment, but in my staging environment it fails and I get a 404 error. I've checked that mod_rewrite is enabled with phpinfo(). I've tried changing a few things like using ^(.*)$ instead of ^ and using /index.php instead of index.php
What else could be the problem?
Figured it out. It was a problem with the configuration of apache. Whoever set it up for the site I'm working on did it like this in the site's .conf file:
<Directory "/data/path/to/directory">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
# and a bunch of rewrite rules...
</Directory>
The AllowOverride None prohibits the use of .htaccess. In our local and development environments, the directory structure is different, so this code doesn't even get applied. That's why the .htaccess was working.
To solve the problem I'll either have to change the line mentioned above to AllowOverride All or add another configuration for the website I'm working on like the one above that does what I wanted to do with .htaccess.
Problems like this shouldn't come up for anyone if their environments are configured appropriately, but if anyone does run into a similar situation, check the configuration of the site in apache!

.htaccess Is Not working in Linux(Debian) Apache2

I am using apache2 (my dummy server) which is already install with my Debian. Every thing goes fine, but now the problem with my .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
It's not working
I think its because of apache2 version which am I using & maybe problems with my code or something I have to config on my server
I want to redirect my url to main index page if its a wrong entry or unavailable
After spending a whole day, I got my answer
In Folder
apache2>>sites-available>> There is file called default
In default we have to change it
From:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
TO:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Its working. It's enabled use of .htaccess files.
I'd like to add that /etc/apache2/mods-available/rewrite.load needs to be enabled:
a2enmod rewrite
On Debian I thought it was enabled by default, but mine wasn't.
This code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,R]
will redirect http://example.com/test.php to http://example.com/index.php?url=test.php if the file doesn't exist. The only difference between my code here and your one is I have [R] instead of [QSA,L] If it still doesn't work for you and you have the htaccess file in the root folder then, I don't think it's a htaccess file problem
Important to note that AllowOverride only works in <Directory> directives and will be ignored if placed inside <Location ...> section; this was my issue and it took me for a nice ride.
Only available in sections AllowOverrideList is valid only
in sections specified without regular expressions, not in
, or sections.
https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride

How to do a RewriteRule when the folder name is equal to an existing file name?

Given the following Folder "de":
.
..
index.php
faq.php
If I try to fire a RewriteRule from my .htaccess (in the parent directory) like this:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^de/test/ de/faq.php [NC,L]
... it works totally fine, but if I try it like this:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^de/faq/ de/faq.php [NC,L]
then the Apache returns a "404 Not found" instead of firing the RewriteRule.
Why does this happen?
Options +FollowSymLinks -MultiViews
If MultiViews is enabled, it will try to search for similar files and folders hence why the rule doesn't work, when you disable it, it stops doing that which is why it works.
For a more in-depth investigation, you may enable your RewriteLog within your web server:
RewriteLog "/some/path/to/file/rewrite.log"
RewriteLogLevel 3
This way you can see how it behaviors and what it looks for when MultiViews is enabled and disabled.

Making pretty permalinks work in WAMP

I am not able to switch to pretty permalinks in WAMP. Changing to any form other than default gives 404 error.
I have switched on the rewrite_module in Apache. I Googled the problem and found that following changes should be made to httpd.conf file. My httpd.conf file stands as
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
I also checked that the .htaccess file is getting created. It reads as
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /vit%20web/events/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /vit%20web/events/index.php [L]
</IfModule>
# END WordPress
All you need to do is turn on the mod_rewrite in the wamp settings tab.
Click Wamp -> Apache -> Apache Modules -> rewrite_module
If you select that then turn on %postname% it should work
Did you reboot Apache after editing httpd.conf?
A bulletproof check for mod_rewrite is to remove the <IfModule>...</IfModule> tags and try running WordPress - if you get a 500 Server Error, mod_rewrite isn't installed.
Also I would recommend changing <Directory /> to <Directory "C:/path/to/server/root"> (note the forward slashes too, even on Windows).
And the deny order should be switched if you're only on a development server;
Order allow,deny
Allow from all
The problem may be:
Whenever you have permalinks in subfolder of your main www folder (i.e.
RewriteBase /subdirectory/
you may need to have a .htaccess file in your main c:\wamp\www folder too.