500 internal server error rewrite

Started by devrim, January 23, 2022, 06:02:00 PM

Previous topic - Next topic

devrim

Hi
Rewrite in my .htaccess file gives 500 internal server error. can you help me please.
.htaccess codes
<IfModule mod_rewrite.c>

    Options +FollowSymLinks
    RewriteEngine on

    # Send request via index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>

</IfModule>

iraqiboy90

#1
Do this instead:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
   RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.EXAMPLE\.TLD[NC]
    RewriteRule ^(.*)$ http://EXAMPLE.TLD/$1 [L,R=301,NC]
    # Send request via index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>

Change EXAMPLE and TLD to your domain name.

Also check the domlogs to see what's actually wrong. The logs will say which line is giving error 500:
tail -f /usr/local/apache/domlogs/YourDomain

devrim

my daily error codes
Options FollowSymLinks not allowed
I did some research but it's very complicated. What should I do with an example?

iraqiboy90

#3
Quote from: devrim on January 23, 2022, 08:50:36 PM
my daily error codes
Options FollowSymLinks not allowed
I did some research but it's very complicated. What should I do with an example?

It's not complicated at all. Remove this line:
Options +FollowSymLinks
or change it to:
Options +SymLinksIfOwnerMatch

I'm wondering why you are even using this, as it is potentially a security issue. SymLinksIfOwnerMatch is better for security.
The reason for getting this error is because the apache template you are using does not let you control the "Options" variable for "FollowSymLinks" because it's not defined in there that you are allowed to:
<Directory "%docroot%">
Options -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>

devrim

Options +SymLinksIfOwnerMatch this code worked for me but gave sql error.
The sql file cannot be dumped with the user added in mysql.
but if we select the user as root, it loads and works.

iraqiboy90

Quote from: devrim on January 25, 2022, 08:10:43 PM
Options +SymLinksIfOwnerMatch this code worked for me but gave sql error.
The sql file cannot be dumped with the user added in mysql.
but if we select the user as root, it loads and works.
Ok, then remove it as well:
Options +SymLinksIfOwnerMatch

Do you want/need it?