[SOLVED] Route ending with .com


#1

Howdy,

First time posting and kind of new to Slim, hope I get this right!

I have a GET route that looks something like:
https://api.domain.ca/rest/contacts/{email_address}

However, when the email address I pass ends with a “.com”, i hit a 403 forbidden error. This is not the case when it ends with “.ca” or “.org”.

Is this a htaccess redirection issue?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

Is it recommended to end my routes with a trailing slash?

Thanks for your help!


#2

hi @jfpaquin

try this

in your route or controller

$this->get(‘testEmail/{email}’, function ($req, $res, $args) {
$emailModel = new EmailModel();
return $res
->withHeader(‘Content-type’, ‘application/json’)
->getBody()
->write(
json_encode(
$emailModel->testEmail($args[‘email’])
)
);
});

in your model

try

public function testEmail($email)
{
try
{
echo $email;
die();

}
catch (\Exception $e){
echo $e->getMessage();
}
}

and try with any email extension


#3

Hello @hdkcreative !

Thanks for taking some time to answer.

The thing is, if the email extension is “.com”, the route’s function is never called.
I get a 403 Forbidden: You don’t have permission to access /rest/contacts/xxxxx@gmail.com.

This is could very well be a server/htaccess config problem, but I can’t find anything on this kind of issue :frowning:


#4

i try xxxxx@gmail.com in my computer… and this work fine…

you are working in local o cloud ?


#5

Cloud, I’m on a hosted VPS.

It seems to be a ModSecurity settings that’s too strict. Disabling ModSecurity result in the correct response.


#6

ahhh ok .perfect…

remember close this post…

ecxample add the word [Solved] TO TITLE :wink: