.htaccess causes Internal Server Error on xampp - .htaccess

I have .htaccess file and i write two command like that:
ReWriteRule ^member/(.*)$ /oz/photos.php?member=$1
ReWriteRule ^(.*)$ /oz/profile.php?username=$1
and this is the fault:
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator at postmaster#localhost 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.29 (Win32) OpenSSL/1.0.2n PHP/5.6.33 Server at localhost
Port 80

Your rule ReWriteRule ^(.*)$ /oz/profile.php?username=$1 is looping the request every time (recursion OR redirect Loop). The all selector in rule is redirecting the redirected request too.
try
ReWriteRule ^member/(.*)$ /oz/photos.php?member=$1
RewriteCond %{REQUEST_URI} !^/oz/.*
ReWriteRule ^(.*)$ /oz/profile.php?username=$1

Go inside your root folder and Delete/Move the.htaccess file from there and bruh! Solved! It's worked for me

Related

How should I write these rewrite rules in my .htaccess file

I have this in my .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^admin\.domain1\.com$ [OR]
RewriteCond %{HTTP_HOST} ^admin\.domain2\.com$ [OR]
RewriteCond %{HTTP_HOST} ^admin\.domain3\.com$
RewriteRule (.*) /path/to/directory/$1 [L]
RewriteCond %{HTTP_HOST} ^admin\.domain4\.com$
RewriteRule (.*) /different/path/$1 [L]
The first block works, but the second block gives me the following 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 [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.
Apache/2.4.29 (Ubuntu) Server at admin.domain4.com.ar Port 80
What am I doing wrong??
The first block works, but the second block gives me an Internal Server error:
Both rules/blocks have the same "issue". The first rule will only "work" if you have another .htaccess file in the /path/to/directory/ that also uses mod_rewrite (perhaps to route the URL?) in order to prevent an internal rewrite loop (the probable cause of your Internal Server Error).
The easiest way to resolve this, if you are on Apache 2.4, is it simply use the END flag, instead of L. For example:
RewriteRule (.*) /different/path/$1 [END]
The L flag only stops the current round of processing, it does not stop all processing by the rewrite engine. On the second pass through the rewrite engine, the pattern (.*) also matches the rewritten request /different/path/<url> which gets further rewritten to /different/path/different/path/<url> etc. resulting in an endless loop, unless there is something to stop it.

problem with .htaccess configuration in cakephp3

i have a problem since one week about my cakephp3 project. i have developped a cakephp3 project in localhost and it works very fine. in my server i have created a subdomain and i have uploaded my project on it. when i execute my project, i have this error message
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#collector.oiecameroun.org 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.
i think the problem is in the .htaccess file root but i don't know what is the problem. i need help please. my php version is 7.2
this is my .htaccess file root content:
# Uncomment the following to prevent the httpoxy vulnerability
# See: https://httpoxy.org/
#<IfModule mod_headers.c>
# RequestHeader unset Proxy
#</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(\.well-known/.*)$ $1 [L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
this is the error log file content
[03-Oct-2019 07:43:11 UTC] PHP Fatal error: You must enable the intl
extension to use CakePHP. in
/home/cp1035698p49/public_html/collector/config/requirements.php on
line 31
and this problem was also resolved

Internal server error when changing to https

My Yii site is giving an internal server error 500 after changing http to https in .htaccess when entering this line of code:
RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
I have a valid SSL because my WordPress sites are working fine with https.
Also my site is a subdomain, but I don't think that would be the problem.
What can it be?
Errorlog: Request exceeded the limit of 10 internal redirects due to probable configuration error.
Fixed issue: Had to insert "rewritebase /" in the .htaccess file.

How can I use apache's rewrite URI to serve 404.php at /404/?

How can I serve this file:
http://www.domain.com/404.php
Whenever my users go to:
http://www.domain.com/404 or http://www.domain.com/404/
Using .htaccess?
I tried this:
RewriteRule 404 /404.php [L]
With the following error:
Request exceeded the limit of 10 internal redirects due to probable configuration error.
Responding with a 404 will cause HTTPd to do the right thing.
RewriteRule 404 - [R=404]

500 Internal Server Error in my wamp server while trying to Rewrite URL in .htaccess

I'm trying to rewrite my bulky, ugly url to a neat one which is converting "art.php?id=$1" in to "art/1", but I encounter a "500 Internal Server Error" What shall I do? Can you help me pleeeease?
This is the .htaccess code I used:
RewriteEngine On
RewriteRule ^art/([A-Za-z0-9-]+)/?$ art.php?id=$1 [NC,L]
This is the Error I encountered:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request. Please contact the server
administrator, admin#localhost 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.
Thanks!
Supposed everything is in the gallery folder, which itself is located in the www root directory. Then put this .htaccess file into the gallery folder as well
RewriteEngine on
RewriteBase /gallery/
# prevent endless loop
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
# serve real content
RewriteRule ^art/([A-Za-z0-9-]+)/?$ art.php?id=$1 [NC,L]
# make pretty URL
RewriteCond %{QUERY_STRING} id=(.+)
RewriteRule ^art.php$ art/%1? [R,NC,L]
Depending on the server you're on, you might want to set the base for rewriting
RewriteEngine On
RewriteBase /art/
RewriteRule ^([A-Za-z0-9-]+)/?$ art.php?id=$1 [NC,L]
that should work just fine

Resources