htaccess 404 loop - internal server error - html

I am a newbie here, made an htaccess with 301 redirect pages with extension (.html) to have no extension. The thing is that when entering into a wrong directory path the 404.html page doesn't work probably because a loop: It displays an error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster#pesto.com.uy 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.
The htaccess file is as follow:
DirectoryIndex index.html
RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !rewrited
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ $1.html [NC,L]
ErrorDocument 404 /404
ErrorDocument 500 /404
Any ideas why this happens?
Warm regards guys

Related

Trying to Redirect Subdomain URL to Subdirectory Index

Subdomain:
live.mysite.com
Subdirectory file to point to:
/my-admin/src/index.html
.htaccess:
RewriteEngine On
#If the host is "sub.domain.com"
RewriteCond %{HTTP_HOST} ^live.mysite.com$ [NC]
#Then rewrite any request to /folder
RewriteRule ^((?!folder).*)$ /my-admin/src/$1 [NC,L]
Results in an internal 500 error. Am I missing something?

Laravel auth/login route not working in server but localhost

I am using laravel 5.4 default authentication system and it is working fine in localhost but when i upload my project to server, it is breaking. when i fill mail and password, it return back me 404 file not found error.
My site url is http://www.happycoder.me/imsRever2.0
You need to configure the .htaccess file as follows:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^imsRever2.0
RewriteRule ^(.*)$ imsRever2.0/$1 [L]
Otherwise, the main web server will not the routing, vs laravel causing the 404 error when the file isn't found.
My htaccess file is below what things i need to change
Options -MultiViews
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Server error in localhost

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]
Error is like this:
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
Sounds like a standard python cgi error message. What exactly are you trying to do? What is the application you are trying to run? Please check the application's logs and so on.

How to add pages to a website (cPanel & Apache)

I'm very new to web development, and know nothing of back-end dev. I have a website hosted by a 3rd party on a Linux server, using cPanel.
I have a index.html page that is loaded when you go to the website www.domain.com and I have a second file page2.html that loads when I go to www.domain.com/page2.html
Problem 1:
I want to be able to go to www.domain.com/page2 and have page2.html load.
Problem 2:
When I go to www.domain.com/page3.html (which doesn't exist) or www.domain.com/page3 or any other non-existent url index.html loads instead of giving me a 404 error. I have made a custom 404 page (404.shtml) which is in the same directory as index.html and page2.html (/public_html/).
How do I get this 404 page to show when I go to a non-existent URL? I checked the error log on cPanel and it shows a File does not exist error.
[Fri Aug 29 20:16:48 2014] [error] [client ...*] File does not exist: /home/adminName/public_html/page3, referer: http://domain.com/page3/
Any pointers in the right direction would be very helpful.
To remove the suffix (.html) from your url, you would need to use .htaccess.
The following will first check if the request is a file (images/css etc.) or directory, then serve the file without the suffix.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
The following will serve a custom 404 error document
ErrorDocument 404 /404.shtml
I just found a similar StackOverflow Question for Problem 1, and the second answer, by Ɓukasz Habrzyk, worked for me.
#example.com/page will display the contents of example.com/page.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
#301 from example.com/page.html to example.com/page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]

After 5 to 5.1 SQL upgrade 500 internal server error

It's on a site that uses symlink - not sure if that's to blame.
I upgraded from SQL 5 to 5.1.
Several sites failed due to the htaccess saying php rather than php5 but that was simple to fix, one site is proving more difficult and I can't seem to find an answer.
The index.php page is actually static html so I'm thinking it must be the .htaccess at fault for this showing a 500 internal server error.
The .htaccess file looks like this:
Options -Indexes +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^(\.cache|images|cgi-bin|ads|css|vids|theme) - [L]
RewriteRule SteelExternalAll\.swf$ /theme/skin-SteelExternal.swf [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[^/]+/(play-|index\.)
RewriteRule ^(games|videos|animations)/([^/]+)/? /$1/play-$2/ [NS,R=permanent,L]
ErrorDocument 404 /index.php