I am getting the following error with my .htaccess file - php

I am getting a Internal Server Error when i use my htaccess file on a sub domain but it works fine with standard domains. I dont really understand how the htaccess file works totally so any help would be greatly aprricated.
.htaccess file
RewriteEngine on
RewriteRule ^([^/\.]+)\.html index.php?act=$1 [L]
Internal Server Error
The server encountered an internal
error or misconfiguration and was
unable to complete your request.
Please contact the server
administrator,
webmaster#-----.com
and inform them of the time the error
occurred, and anything you might have
done that may have caused the error.
More information about this error may
be available in the server error log.
Additionally, a 500 Internal Server
Error error was encountered while
trying to use an ErrorDocument to
handle the request.

When using RewriteRules, always, always use the conditions associated with the involved module. In case the module is not available, rewrites won't work (and your website will probably be broken because it relies on rewrite rules ;-)) but you won't get a 500 error:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([^/\.]+)\.html index.php?act=$1 [L]
</IfModule>
If you don't get a 500 error after this, then the rewrite module is not loaded in your subdomain.
If you still get it, it's probably a redirect loop.

This is a punt - may be well off base.
Is your subdomain is based in a folder within the standard webroot?
ie subdomain.server.com is rooted in a folder subdomain within the webroot folder for server.com. So the webroot is something like /httpdocs/ and the subdomain is /httpdocs/subdomain/.
You may just need to define the RewriteBase as that folder
RewriteEngine on
RewriteBase /subdomain/
RewriteRule ^([^/\.]+)\.html index.php?act=$1 [L]
Does that help?

Related

WordPress gives 500 server error after changing the site url to work with Weglot translation plugin

I am a new WordPress user and recently I added Weglot multilingual support to my website. I wanted to have English as my default URL so I foolishly try to change the site address URL and WordPress address URL at Settings->General to https://example.com/en, which started the problem, I was not able to access WordPress itself.
Then I changed the WordPress address URL and site address URL in the WordPress database wp_options table. Now I am able to access WordPress but my other pages or the URL generated by Weglot to support multilingual stuff like https://example.com/en/servizi/ is not loading and giving the same error as below:
Internal Server Error The server encountered an internal error or
misconfiguration and was unable to complete your request.
Please contact the server administrator at [no address given] to
inform them of the time this error occurred, and the actions you
performed just before this error.
More information about this error may be available in the server error
log.
Additionally, a 500 Internal Server Error error was encountered while
trying to use an ErrorDocument to handle the request.
Apache/2.4.41 Server at example.com Port 443
And when I checked respective pages, it shows below error for wp-asset-clean-up: CSS and javascript manager plugin.
Note: The checked URL returned an error when fetching the assets via
AJAX call. This could be because of a firewall that is blocking the
AJAX call, a redirect loop or an error in the script that is
retrieving the output which could be due to an incompatibility between
the plugin and the WordPress setup you are using.
Here is the response from the call:
Status Code Error: 500 * for more information about client and server
errors, check this link Suggestion: Select “WP Remote Post” as a
method of retrieving the assets from the “Settings” page. If that
doesn’t fix the issue, just use “Manage in Front-end” option which
should always work and submit a ticket about your problem. Output:
Internal Server Error The server encountered an internal error or
misconfiguration and was unable to complete your request.
Please contact the server administrator at [no address given] to
inform them of the time this error occurred, and the actions you
performed just before this error.
More information about this error may be available in the server error
log.
Additionally, a 500 Internal Server Error error was encountered while
trying to use an ErrorDocument to handle the request.
Apache/2.4.41 Server at example.com Port 443
Did you flush your permalinks? Go to Wordpress admin -> Settings -> Permalinks and click save, It should flush your permalinks.
After that check your .htaccess, I had simular issue once and I had to change the .htaccess to work properly.
This seems like a problem from .htaccess...
First check If .htaccess looks like this.
# 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
After that try this solution, this worked for me once when I had that issue.
DirectoryIndex index.php
RewriteEngine on
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php [L]
Then check your apache logs via ssh
sudo tail /var/log/apache2/error.log
Last thing I recommend If you have any cache plugins disable them.
Oh and all the time try to flush your permalinks.
1. Set your WP urls correctly
Firstly, you haven't moved the location of the WP installation, so your Site URL shouldn't change. If you want the WP site to run from /en by default, then you only need to change your Home URL.
WP_SITEURL: https://example.com/
WP_HOME : https://example.com/en/
2. Change all the URLs in the database
WP websites store a lot of full URLs in the database, and changing the site & home URLs doesn't change the URLs in the db entries.
I assume you need to change all your urls to use /en/ for the site to work (that's specific to the plugin so I can only guess based on your question) - if so you need to find all the URLs in the database that use https://example.com/ and replace them with https://example.com/en/.
You could do this manually, but it can be tricky so my suggestion is to use a plugin such as which will find and change all the URLs. The one I use is Better Search Replace but there are others.
Make a backup first! Of course, before you do this make sure you make a backup - once you change the database, you can't just undo those changes!
I'm not familiar this plugin, so I'm not sure if there are plugin-specific changes after that - that's a question for the plugin support as its specific to that plugin and is beyond the scope of how we can help out here. But those steps should get you back up & running again anyway.
TIP - resetting your Home and Site URLs after making a mistake
If you change your Home and Site URLs and can no longer get the site to work, you can override the WP Home and Site address URLs in your wp-config.php file - just add these lines near the top:
define('WP_HOME','https://example.com/');
define('WP_SITEURL','https://example.com/');
Now you can get back into the admin and website, to fix whatever changes you made.

slim rest api work fine on localhost but it returning error 500 on shared hosting?

I have developed an application using angualar and php with slim and it works fine in localhost , but slim rest api showing error code 500 on shared hosting, How to solve this issue ?
when i try to check it showing below message
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, webmaster#demoems.aaaaa.com
and inform them of the time the error occurred, and anything you might
have done that may have caused the error.
More information about this error may be available in the server error
log.
Additionally, a 500 Internal Server Error error was encountered while
trying to use an ErrorDocument to handle the request.
If you are using Apache
you must create .htaccess file with this configuration
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
Also you must config your shared hosting apache config file
Find var/www/ Block
and change
this
AllowOverride none
To
AllowOverride All
problem solved by setting folder ,file permission to 755,644

Why does this Rewrite rule throws a 500 inside .htaccess file?

on a server with PHP and mod_rewrite I have the following .htaccess in the document root:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule .(rewriteme)$ rewrite.php [L]
</IfModule>
When I make a request to http://theserver.com/arewriteme, I get a 500 internal server error.
But on my local system, the rule above works great and the script rewrite.php is executed (it simply echoes It works!) when I request http://localhost/arewriteme:
<?php echo "It works!"; ?>
Why do I get a 500 error on the remote server though? I don't have access to the global Apache configuration, but I am sure the module gets loaded as `phpinfo() shows:
I looked at different questions here on SO, but basically all say that it the error is due a syntax error within .htaccess (which is not my case because the rule works on localhost).
So, maybe, there's something in the global configuration of Apache? Maybe the creation of .htaccess is somehow denied? Could it be possible?
Thanks for the attention.
EDIT: I was able to contact the hosting provider and they told me that they disabled .htaccess throught the whole htdocs directory. How did they do that so that the server thrown a 500 Internal Server Error? AllowOverride None inside the main Apache won't do the job because in this case Apache would simply ignore the rules inside the .htaccess but won't throw any error...

Internal Server Error .htaccess

I have a problem with my .htaccess file.
In my .htaccess file I have this:
RewriteEngine on
RewriteRule ^user/([0-9a-zA-Z]+) user.php?u=$1 [NC, L]
And it is placed in my C:/../wamp/www/mysite/
My site worked before I had this file, so I'm not sure what I'm doing wrong.
I'm kind of new to this aswell so it's bound to go wrong.
Whenever I run my site I get the error:
Internal Server Error
"The server encountered an internal error or misconfiguration and was unable to complete your request."
You haven't finished the rule, change it to:
RewriteRule ^user/([0-9a-zA-Z]+)$ user.php?u=$1 [NC,L]
#-------------------------------^
Okay, now that it looks like you haven't enabled the rewrite engine. Check .htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration for more information on how to enable it.
Update: If you are struggling with this, there's a Youtube video on how to do it: Youtube: How to enable rewrite module in WAMP Server?
Update: If you get Bad Flag Delimiters error, please don't give any spaces between the flags. For more information, see RewriteRule Error: Bad flag delimiters.

500 internal server error comes up when i use .htaccess file in wamp server

i was trying to rewrite my post url with htaccess file when i put it into my project directory with following code in the htaccess file 500 internal error comes up, but when i left it(htaccess) blank without any code the page loads perfectly.
RewriteEngine on
RewriteRule ^post post.php
Error is:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at admin#example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
what might be the issue, is there any permission need to be granted or any directives need to be on in config file or php.ini i am new in php development. plz help.
Thank you
It must be
RewriteEngine on
RewriteRule ^post$ post.php
try:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^post post.php [L,R=301]
</IfModule>
With this code the error should disappear but it's possible that your rule is not applying correctly, in this case we will fix

Categories