问:
How to disable button until good validation in wpf mvvm
How can I disable button until good textbox validation?
I have done some stuff but I don't know how to hide button until good validation in the right way with using MVVM pattern.
I am still learning this MVVM pattern.
Here are my fragments of code:

ValidationRule Class:

```<code>public class NotEmptyValidationRule : ValidationRule
{
    public override ValidationResult Validate(object value, CultureInfo cultureInfo)
    {
        return string.IsNullOrWhiteSpace((value ?? "").ToString())
            ? new ValidationResult(false, "Field is required")
            : ValidationResult.ValidResult;
    }
}
</code>```

xaml:

```<code><TextBox
Style="{StaticResource MaterialDesignFilledTextFieldTextBox}"
AcceptsReturn="True"
TextWrapping="Wrap"
materialDesign:HintAssist.Hint="Content"
IsEnabled="{Binding Path=IsChecked,
ElementName=MaterialDesignOutlinedTextFieldTextBoxEnabledComboBox}"
MaxLength="1000" materialDesign:ValidationAssist.UsePopup="True">
        <TextBox.Text>
            <Binding Path="Task.Content" UpdateSourceTrigger="PropertyChanged">
                <Binding.ValidationRules>
                    <domain:NotEmptyValidationRule
                     ValidatesOnTargetUpdated="True" />
                </Binding.ValidationRules>
            </Binding>
        </TextBox.Text>
    </TextBox>
</code>```

ViewModel:

```<code>private ICommand _submitCommand;
public ICommand SubmitCommand
{
   get
   {
       if (_submitCommand == null)
       {
          _submitCommand = new RelayCommand(SubmitExecute, anSubmitExecute, false);
       }
       return _submitCommand;
    }
}

private void SubmitExecute(object parameter)
{
     Task.Id++;
     Tasks.Add(Task);
}

private bool CanSubmitExecute(object parameter)
{
     // What can I do to prevent to show this button when validation
     // failed
     return true;
}
</code>```

答:
You should either implement the INotifyDataErrorInfo interface in your Task class, or implement it in your view model class and wrap the databound Task.Content property, e.g.:

```<code>private RelayCommand _submitCommand;
public ICommand SubmitCommand
{
    get
    {
        if (_submitCommand == null)
        {
            _submitCommand = new RelayCommand(SubmitExecute, CanSubmitExecute, false);
        }
        return _submitCommand;
    }
}

private void SubmitExecute(object parameter)
{
    Task.Id++;
    Tasks.Add(Task);
}

public string Content
{
    get { return Task.Content; }
    set
    {
        Task.Content = value;
        if (string.IsNullOrEmpty(Task.Content))
            _validationErrors[nameof(Content)] = "Field is required";
        else
            _validationErrors.Remove(nameof(Content));
        ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Content)));
        _submitCommand.RaiseCanExecuteChanged();
    }
}

private bool CanSubmitExecute(object parameter)
{
    return HasErrors;
}

#region INotifyDataErrorInfo
private readonly Dictionary<string, string> _validationErrors = new Dictionary<string, string>();

public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;

public System.Collections.IEnumerable GetErrors(string propertyName)
{
    if (string.IsNullOrEmpty(propertyName)
        || !_validationErrors.ContainsKey(propertyName))
        return null;

    return new string[1] { _validationErrors[propertyName] };
}

public bool HasErrors
{
    get { return _validationErrors.Count > 0; }
}
#endregion
</code>```

XAML:

```<code><TextBox Text="{Binding Content, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />
</code>```

You should not use a validation rule. They are not MVVM friendly. Please refer to this blog post for more information.

You also need to raise the CanExecuteChanged event of the ICommand. How to do this depends on the implementation. Most implementations have a method called something like  RaiseCanExecuteChanged() or similar.

WPF 4.5: Validating Data in Using the INotifyDataErrorInfo Interface

Body:
How can I disable button until good textbox validation?
I have done some stuff but I don't know how to hide button until good validation in the right way with using MVVM pattern.
I am still learning this MVVM pattern.
Here are my fragments of code:

ValidationRule Class:

public class NotEmptyValidationRule : ValidationRule
{
    public override ValidationResult Validate(object value, CultureInfo cultureInfo)
    {
        return string.IsNullOrWhiteSpace((value ?? "").ToString())
            ? new ValidationResult(false, "Field is required")
            : ValidationResult.ValidResult;
    }
}

xaml:

<TextBox
Style="{StaticResource MaterialDesignFilledTextFieldTextBox}"
AcceptsReturn="True"
TextWrapping="Wrap"
materialDesign:HintAssist.Hint="Content"
IsEnabled="{Binding Path=IsChecked,
ElementName=MaterialDesignOutlinedTextFieldTextBoxEnabledComboBox}"
MaxLength="1000" materialDesign:ValidationAssist.UsePopup="True">
        <TextBox.Text>
            <Binding Path="Task.Content" UpdateSourceTrigger="PropertyChanged">
                <Binding.ValidationRules>
                    <domain:NotEmptyValidationRule
                     ValidatesOnTargetUpdated="True" />
                </Binding.ValidationRules>
            </Binding>
        </TextBox.Text>
    </TextBox>

ViewModel:

private ICommand _submitCommand;
public ICommand SubmitCommand
{
   get
   {
       if (_submitCommand == null)
       {
          _submitCommand = new RelayCommand(SubmitExecute, anSubmitExecute, false);
       }
       return _submitCommand;
    }
}

private void SubmitExecute(object parameter)
{
     Task.Id++;
     Tasks.Add(Task);
}

private bool CanSubmitExecute(object parameter)
{
     // What can I do to prevent to show this button when validation
     // failed
     return true;
}

Body:
You should either implement the INotifyDataErrorInfo interface in your Task class, or implement it in your view model class and wrap the databound Task.Content property, e.g.:

private RelayCommand _submitCommand;
public ICommand SubmitCommand
{
    get
    {
        if (_submitCommand == null)
        {
            _submitCommand = new RelayCommand(SubmitExecute, CanSubmitExecute, false);
        }
        return _submitCommand;
    }
}

private void SubmitExecute(object parameter)
{
    Task.Id++;
    Tasks.Add(Task);
}

public string Content
{
    get { return Task.Content; }
    set
    {
        Task.Content = value;
        if (string.IsNullOrEmpty(Task.Content))
            _validationErrors[nameof(Content)] = "Field is required";
        else
            _validationErrors.Remove(nameof(Content));
        ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Content)));
        _submitCommand.RaiseCanExecuteChanged();
    }
}

private bool CanSubmitExecute(object parameter)
{
    return HasErrors;
}

#region INotifyDataErrorInfo
private readonly Dictionary<string, string> _validationErrors = new Dictionary<string, string>();

public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;

public System.Collections.IEnumerable GetErrors(string propertyName)
{
    if (string.IsNullOrEmpty(propertyName)
        || !_validationErrors.ContainsKey(propertyName))
        return null;

    return new string[1] { _validationErrors[propertyName] };
}

public bool HasErrors
{
    get { return _validationErrors.Count > 0; }
}
#endregion

XAML:

<TextBox Text="{Binding Content, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />

You should not use a validation rule. They are not MVVM friendly. Please refer to this blog post for more information.

You also need to raise the CanExecuteChanged event of the ICommand. How to do this depends on the implementation. Most implementations have a method called something like  RaiseCanExecuteChanged() or similar.

WPF 4.5: Validating Data in Using the INotifyDataErrorInfo Interface


来源: stackexchange

问:
'LGSideMenucontroller' not open in all viewcontroller in swift 4
In my app I am using 'LGSideMenuController' for sidemenu. Now in my app 'loginviewcontroller' then 'otpviewcontroller' and then 'homeviewcontroller' and other 'viewcontroller'. now my side menu open in all viewcontroller after 'homeviewcontroller'. I am able to open side menu from 'homeviewcontroller'. but in other viewcontroller I am not.

I did code for open sidemenu in 'appdelegate.swift' and also in 'homeviewcontroller'.

in my appdelegate.swift my code for open sidemenu.

```<code>    let storyBoard = UIStoryboard.init(name: "Main", bundle: nil)

    let rootviewcontroller = storyBoard.instantiateViewController(withIdentifier: "HomeVC") as! HomeVC
    let navigation = UINavigationController.init(rootViewController: rootviewcontroller)
    let sideMenuVC = storyBoard.instantiateViewController(withIdentifier: "SideMenuVC") as! SideMenuVC

    let sideMenuController = LGSideMenuController(rootViewController: navigation,
                                                  leftViewController: sideMenuVC,
                                                  rightViewController: nil)
    sideMenuController.leftViewWidth = 280.0
    sideMenuController.leftViewPresentationStyle = .scaleFromBig

    self.window?.rootViewController = sideMenuController
    self.window?.makeKeyAndVisible()
</code>```

and in my homeviewcontroller i make code like this

```<code>@IBAction func sideMenuAction(_ sender: UIBarButtonItem) {

    self.sideMenuController?.showLeftView(animated: true, completionHandler: nil)
}
</code>```

it works in homeviewcontroller but other viewcontroller not working.

答: You need to use a Container View and make it the root controller. Then, you'd be able to achieve what you're trying to do</p>

ContentLicense: CC BY-SA 4.0

Body:
In my app I am using 'LGSideMenuController' for sidemenu. Now in my app 'loginviewcontroller' then 'otpviewcontroller' and then 'homeviewcontroller' and other 'viewcontroller'. now my side menu open in all viewcontroller after 'homeviewcontroller'. I am able to open side menu from 'homeviewcontroller'. but in other viewcontroller I am not.

I did code for open sidemenu in 'appdelegate.swift' and also in 'homeviewcontroller'.

in my appdelegate.swift my code for open sidemenu.

    let storyBoard = UIStoryboard.init(name: "Main", bundle: nil)

    let rootviewcontroller = storyBoard.instantiateViewController(withIdentifier: "HomeVC") as! HomeVC
    let navigation = UINavigationController.init(rootViewController: rootviewcontroller)
    let sideMenuVC = storyBoard.instantiateViewController(withIdentifier: "SideMenuVC") as! SideMenuVC

    let sideMenuController = LGSideMenuController(rootViewController: navigation,
                                                  leftViewController: sideMenuVC,
                                                  rightViewController: nil)
    sideMenuController.leftViewWidth = 280.0
    sideMenuController.leftViewPresentationStyle = .scaleFromBig

    self.window?.rootViewController = sideMenuController
    self.window?.makeKeyAndVisible()

and in my homeviewcontroller i make code like this

@IBAction func sideMenuAction(_ sender: UIBarButtonItem) {

    self.sideMenuController?.showLeftView(animated: true, completionHandler: nil)
}

it works in homeviewcontroller but other viewcontroller not working.


问:
Embed message loop doesnt stop
If I type pingtest, my bot is sending the embed message over and over again (infinite loop)</p>

```<code>if (message.content='pingtest') {
    message.channel.send({embed: {

            color: 000000,
            author: {
              name: client.user.username,
              icon_url: client.user.avatarURL
            },
            title: "A RAID HAS BEGUN (for the Dark Side)",
            description: "",
            fields: [{
                name: "------------------------------",
                value:"Write !raid to enter."
              }

            ],
            footer: {
              icon_url: client.user.avatarURL,
            }
          }
        });
}
</code>```

答:
you need to make embed for</p>

```<code>if(message.content.startsWith('pingtest'))
   let embed = new Discord.Embed
       .setColor('color')
       .setTitle('title')
       .setAuthor(`${client.user.username}`)
       .setDescreption('Descreption')
       .addField('Field)
      message.channel.send(embed)
</code>```

Title: Embed message loop doesnt stop

Body:
If I type pingtest, my bot is sending the embed message over and over again (infinite loop)

if (message.content='pingtest') {
    message.channel.send({embed: {

            color: 000000,
            author: {
              name: client.user.username,
              icon_url: client.user.avatarURL
            },
            title: "A RAID HAS BEGUN (for the Dark Side)",
            description: "",
            fields: [{
                name: "------------------------------",
                value:"Write !raid to enter."
              }

            ],
            footer: {
              icon_url: client.user.avatarURL,
            }
          }
        });
}

Body:
you need to make embed for

if(message.content.startsWith('pingtest'))
   let embed = new Discord.Embed
       .setColor('color')
       .setTitle('title')
       .setAuthor(`${client.user.username}`)
       .setDescreption('Descreption')
       .addField('Field)
      message.channel.send(embed)


问:
Do you understand the problem on this POST request with lambda function?
I use netlify lambda functions for CRUD operations on my project but i have an error on the POST operation

I use angular front, netlify functions and faunaDB

my lambda:

```<code>/* code from functions/todos-create.js */
import faunadb from 'faunadb' /* Import faunaDB sdk */

/* configure faunaDB Client with our secret */
const q = faunadb.query
const client = new faunadb.Client({
  secret: process.env.FAUNADB_SECRET
})

/* export our lambda function as named "handler" export */
exports.handler = (event, context, callback) => {
  /* parse the string body into a useable JS object */
  console.log('<<<<<<<<<' + "      " + event.body + "       " + '>>>>>>>>>')
  const eventBody = JSON.stringify(event.body)
  const data = JSON.parse(eventBody)
  console.log("Function `todo-create` invoked", data)
  const todoItem = {
    data: data
  }
  /* construct the fauna query */
  return client.query(q.Create(q.Ref("classes/todos"), todoItem))
  .then((response) => {
    console.log("success", response)
    /* Success! return the response with statusCode 200 */
    return callback(null, {
      statusCode: 200,
      body: JSON.stringify(response)
    })
  }).catch((error) => {
    console.log("error", error)
    /* Error! return the error with statusCode 400 */
    return callback(null, {
      statusCode: 400,
      body: JSON.stringify(error)
    })
  })
}
</code>```

a piece of my component:

```<code>public myTodo = { title: 'What I had for breakfast ..',
                    completed: true };

onSubmit() {
    this.missionService.createTodo(this.myTodo).then((response) => {
      console.log('console log of missionService.createTodo ---->');
      console.log(this.myTodo);
      console.log('API response', response);
    }).catch((error) => {
      console.log('API error', error);
    });
  }

</code>```

my service:

```<code>  createTodo(data) {
    console.log('console log of createTodo ---->');
    console.log(data);
    return fetch('/.netlify/functions/todos-create', {
      body: JSON.stringify(data),
      method: 'POST'
    }).then(response => {
      return response.json();
    });
  }
</code>```

And finnaly the execution error....

```<code>Request from ::ffff:127.0.0.1: POST /todos-create
[BACK] [LAMBDA] <<<<<<<<<      {"title":"What I had for breakfast ..","completed":true}       >>>>>>>>>
[BACK] [LAMBDA] Function `todo-create` invoked {"title":"What I had for breakfast ..","completed":true}
[BACK] [LAMBDA] error { [BadRequest: validation failed]
[BACK] [LAMBDA]   name: 'BadRequest',
[BACK] [LAMBDA]   message: 'validation failed',
[BACK] [LAMBDA]   requestResult:
[BACK] [LAMBDA]    RequestResult {
[BACK] [LAMBDA]      client:
[BACK] [LAMBDA]       Client {
[BACK] [LAMBDA]         _baseUrl: 'https://db.fauna.com:443',
[BACK] [LAMBDA]         _timeout: 60000,
[BACK] [LAMBDA]         _secret: '******************'
[BACK] [LAMBDA]         _observer: null,
[BACK] [LAMBDA]         _lastSeen: 1559144535321508 },
[BACK] [LAMBDA]      method: 'POST',
[BACK] [LAMBDA]      path: '',
[BACK] [LAMBDA]      query: null,
[BACK] [LAMBDA]      requestRaw: undefined,
[BACK] [LAMBDA]      requestContent: Expr { raw: [Object] },
[BACK] [LAMBDA]      responseRaw:
[BACK] [LAMBDA]       '{"errors":[{"position":[],"code":"validation failed","description":"Instance data is not valid.","failures":[{"field":["data"],"code":"invalid type","description":"Invalid type String, expected type Map."}]}]}',
[BACK] [LAMBDA]      responseContent: { errors: [Array] },
[BACK] [LAMBDA]      statusCode: 400,
[BACK] [LAMBDA]      responseHeaders:
[BACK] [LAMBDA]       { 'content-type': 'application/json;charset=utf-8',
[BACK] [LAMBDA]         date: 'Wed, 29 May 2019 15:42:15 GMT',
[BACK] [LAMBDA]         'x-bus-bytes-in': '0',
[BACK] [LAMBDA]         'x-bus-bytes-out': '0',
[BACK] [LAMBDA]         'x-bus-messages-in': '0',
[BACK] [LAMBDA]         'x-bus-messages-out': '0',
[BACK] [LAMBDA]         'x-faunadb-build': '2.6.4.rc4-3fa8865',
[BACK] [LAMBDA]         'x-faunadb-host': 'ec2-35-173-239-41.compute-1.amazonaws.com',
[BACK] [LAMBDA]         'x-points-network-out': '0.0',
[BACK] [LAMBDA]         'x-points-storage-read': '0.0',
[BACK] [LAMBDA]         'x-points-storage-write': '0.0',
[BACK] [LAMBDA]         'x-points-total': '0.0',
[BACK] [LAMBDA]         'x-query-bytes-in': '129',
[BACK] [LAMBDA]         'x-query-bytes-out': '209',
[BACK] [LAMBDA]         'x-query-time': '0',
[BACK] [LAMBDA]         'x-read-ops': '0',
[BACK] [LAMBDA]         'x-storage-bytes-read': '0',
[BACK] [LAMBDA]         'x-storage-bytes-write': '0',
[BACK] [LAMBDA]         'x-storage-ops-delete': '0',
[BACK] [LAMBDA]         'x-storage-ops-read': '0',
[BACK] [LAMBDA]         'x-storage-ops-write': '0',
[BACK] [LAMBDA]         'x-txn-delay': '0',
[BACK] [LAMBDA]         'x-txn-retries': '0',
[BACK] [LAMBDA]         'x-txn-time': '1559144535321508',
[BACK] [LAMBDA]         'x-write-ops': '0',
[BACK] [LAMBDA]         'content-length': '209',
[BACK] [LAMBDA]         connection: 'Close' },
[BACK] [LAMBDA]      startTime: 1559144535024,
[BACK] [LAMBDA]      endTime: 1559144535439 } }
[BACK] [LAMBDA] Response with status 400 in 417 ms.
[BACK] [LAMBDA] (node:10193) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'statusCode' of undefined
[BACK] [LAMBDA]     at callback (/home/mathieu/Bureau/acrabadabra/Acrabadabra/node_modules/netlify-lambda/lib/serve.js:35:42)
[BACK] [LAMBDA]     at /home/mathieu/Bureau/acrabadabra/Acrabadabra/node_modules/netlify-lambda/lib/serve.js:67:7
[BACK] [LAMBDA]     at tryCatch (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1803:12)
[BACK] [LAMBDA]     at invokeCallback (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1818:13)
[BACK] [LAMBDA]     at publish (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1792:7)
[BACK] [LAMBDA]     at flush (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1522:5)
[BACK] [LAMBDA]     at process._tickCallback (internal/process/next_tick.js:61:11)
[BACK] [LAMBDA] (node:10193) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
</code>```

GET request is functional, i tried it.
Do you have any idea of the problem please ?

答:
My solution, add a second JSON parse in parameter variable of the request:</p>

```<code>const todoItem = {
    data: JSON.parse(data)
  }
</code>```

Body:
I use netlify lambda functions for CRUD operations on my project but i have an error on the POST operation

I use angular front, netlify functions and faunaDB

my lambda:

/* code from functions/todos-create.js */
import faunadb from 'faunadb' /* Import faunaDB sdk */

/* configure faunaDB Client with our secret */
const q = faunadb.query
const client = new faunadb.Client({
  secret: process.env.FAUNADB_SECRET
})

/* export our lambda function as named "handler" export */
exports.handler = (event, context, callback) => {
  /* parse the string body into a useable JS object */
  console.log('<<<<<<<<<' + "      " + event.body + "       " + '>>>>>>>>>')
  const eventBody = JSON.stringify(event.body)
  const data = JSON.parse(eventBody)
  console.log("Function `todo-create` invoked", data)
  const todoItem = {
    data: data
  }
  /* construct the fauna query */
  return client.query(q.Create(q.Ref("classes/todos"), todoItem))
  .then((response) => {
    console.log("success", response)
    /* Success! return the response with statusCode 200 */
    return callback(null, {
      statusCode: 200,
      body: JSON.stringify(response)
    })
  }).catch((error) => {
    console.log("error", error)
    /* Error! return the error with statusCode 400 */
    return callback(null, {
      statusCode: 400,
      body: JSON.stringify(error)
    })
  })
}

a piece of my component:

public myTodo = { title: 'What I had for breakfast ..',
                    completed: true };

onSubmit() {
    this.missionService.createTodo(this.myTodo).then((response) => {
      console.log('console log of missionService.createTodo ---->');
      console.log(this.myTodo);
      console.log('API response', response);
    }).catch((error) => {
      console.log('API error', error);
    });
  }

my service:

  createTodo(data) {
    console.log('console log of createTodo ---->');
    console.log(data);
    return fetch('/.netlify/functions/todos-create', {
      body: JSON.stringify(data),
      method: 'POST'
    }).then(response => {
      return response.json();
    });
  }

And finnaly the execution error....

Request from ::ffff:127.0.0.1: POST /todos-create
[BACK] [LAMBDA] <<<<<<<<<      {"title":"What I had for breakfast ..","completed":true}       >>>>>>>>>
[BACK] [LAMBDA] Function `todo-create` invoked {"title":"What I had for breakfast ..","completed":true}
[BACK] [LAMBDA] error { [BadRequest: validation failed]
[BACK] [LAMBDA]   name: 'BadRequest',
[BACK] [LAMBDA]   message: 'validation failed',
[BACK] [LAMBDA]   requestResult:
[BACK] [LAMBDA]    RequestResult {
[BACK] [LAMBDA]      client:
[BACK] [LAMBDA]       Client {
[BACK] [LAMBDA]         _baseUrl: 'https://db.fauna.com:443',
[BACK] [LAMBDA]         _timeout: 60000,
[BACK] [LAMBDA]         _secret: '******************'
[BACK] [LAMBDA]         _observer: null,
[BACK] [LAMBDA]         _lastSeen: 1559144535321508 },
[BACK] [LAMBDA]      method: 'POST',
[BACK] [LAMBDA]      path: '',
[BACK] [LAMBDA]      query: null,
[BACK] [LAMBDA]      requestRaw: undefined,
[BACK] [LAMBDA]      requestContent: Expr { raw: [Object] },
[BACK] [LAMBDA]      responseRaw:
[BACK] [LAMBDA]       '{"errors":[{"position":[],"code":"validation failed","description":"Instance data is not valid.","failures":[{"field":["data"],"code":"invalid type","description":"Invalid type String, expected type Map."}]}]}',
[BACK] [LAMBDA]      responseContent: { errors: [Array] },
[BACK] [LAMBDA]      statusCode: 400,
[BACK] [LAMBDA]      responseHeaders:
[BACK] [LAMBDA]       { 'content-type': 'application/json;charset=utf-8',
[BACK] [LAMBDA]         date: 'Wed, 29 May 2019 15:42:15 GMT',
[BACK] [LAMBDA]         'x-bus-bytes-in': '0',
[BACK] [LAMBDA]         'x-bus-bytes-out': '0',
[BACK] [LAMBDA]         'x-bus-messages-in': '0',
[BACK] [LAMBDA]         'x-bus-messages-out': '0',
[BACK] [LAMBDA]         'x-faunadb-build': '2.6.4.rc4-3fa8865',
[BACK] [LAMBDA]         'x-faunadb-host': 'ec2-35-173-239-41.compute-1.amazonaws.com',
[BACK] [LAMBDA]         'x-points-network-out': '0.0',
[BACK] [LAMBDA]         'x-points-storage-read': '0.0',
[BACK] [LAMBDA]         'x-points-storage-write': '0.0',
[BACK] [LAMBDA]         'x-points-total': '0.0',
[BACK] [LAMBDA]         'x-query-bytes-in': '129',
[BACK] [LAMBDA]         'x-query-bytes-out': '209',
[BACK] [LAMBDA]         'x-query-time': '0',
[BACK] [LAMBDA]         'x-read-ops': '0',
[BACK] [LAMBDA]         'x-storage-bytes-read': '0',
[BACK] [LAMBDA]         'x-storage-bytes-write': '0',
[BACK] [LAMBDA]         'x-storage-ops-delete': '0',
[BACK] [LAMBDA]         'x-storage-ops-read': '0',
[BACK] [LAMBDA]         'x-storage-ops-write': '0',
[BACK] [LAMBDA]         'x-txn-delay': '0',
[BACK] [LAMBDA]         'x-txn-retries': '0',
[BACK] [LAMBDA]         'x-txn-time': '1559144535321508',
[BACK] [LAMBDA]         'x-write-ops': '0',
[BACK] [LAMBDA]         'content-length': '209',
[BACK] [LAMBDA]         connection: 'Close' },
[BACK] [LAMBDA]      startTime: 1559144535024,
[BACK] [LAMBDA]      endTime: 1559144535439 } }
[BACK] [LAMBDA] Response with status 400 in 417 ms.
[BACK] [LAMBDA] (node:10193) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'statusCode' of undefined
[BACK] [LAMBDA]     at callback (/home/mathieu/Bureau/acrabadabra/Acrabadabra/node_modules/netlify-lambda/lib/serve.js:35:42)
[BACK] [LAMBDA]     at /home/mathieu/Bureau/acrabadabra/Acrabadabra/node_modules/netlify-lambda/lib/serve.js:67:7
[BACK] [LAMBDA]     at tryCatch (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1803:12)
[BACK] [LAMBDA]     at invokeCallback (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1818:13)
[BACK] [LAMBDA]     at publish (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1792:7)
[BACK] [LAMBDA]     at flush (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1522:5)
[BACK] [LAMBDA]     at process._tickCallback (internal/process/next_tick.js:61:11)
[BACK] [LAMBDA] (node:10193) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)

GET request is functional, i tried it.
Do you have any idea of the problem please ?

Body:
My solution, add a second JSON parse in parameter variable of the request:

const todoItem = {
    data: JSON.parse(data)
  }


问:
Ajax GET returns 404 not found on CentOS
So I have a project in Laravel in which I use Ajax to move between views, so no data, only GET request.

This works fine on my local machine but I uploaded it to my VPS and when I click the button that should take me to another view, I get this error:

```<code>GET http://172.106.202.124/trabajos?_=1559303733962 404 (Not Found)
</code>```

So I've done some research and found some people with the same issue, but I haven't found any working answer.

Some said to modify .htaccess, I already did that and it's the same for me.

I've noticed that if I write /index.php/trabajos in the URL it gives me 'trabajos' view, but if I remove the /index.php/ it just gives me 'Not found'

This is my js code:

```<code> $(document).on('click', '#button1', function() {
        $.ajax({
                method: "GET",
                url:'/trabajos',
                success:function(result) {

                        $("#app").html(result).hide().fadeIn(1200);
                },
                error : function(e){
                        console.info("Error");
                }
                });
        });

</code>```

And these are my routes:

```<code>Route::get('/', function () {
    return view('master');
});
Route::get('/main', function () {
    return view('main');
});
Route::get('/trabajos', function(){
    return view('menu.trabajos');
});
Route::get('/contacto', function(){
    return view('menu.contacto');
});
Route::get('/empresa', function(){
    return view('menu.empresa');
});
</code>```

This is my httpd config:

```<code>#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin root@localhost

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory /var/www/laravel/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html/imprenta/public/"

#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
    Require all denied
</Files>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error_log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    #CustomLog "logs/access_log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to
    # exist in your server's namespace, but do not anymore. The client
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig /etc/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default.  To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    #
    # The mod_mime_magic module allows the server to use various hints from the
    # contents of the file itself to determine its type.  The MIMEMagicFile
    # directive tells the module where the hint definitions are located.
    #
    MIMEMagicFile conf/magic
</IfModule>

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults if commented: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile on

# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf
</code>```

I get this error with the config:

```<code>* httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2019-05-31 08:44:37 EDT; 24s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 28971 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 28969 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 28969 (code=exited, status=1/FAILURE)

May 31 08:44:37 server.imprentasanchez.tk systemd[1]: Starting The Apache HTTP Server...
May 31 08:44:37 server.imprentasanchez.tk httpd[28969]: AH00534: httpd: Configuration erro....
May 31 08:44:37 server.imprentasanchez.tk systemd[1]: httpd.service: main process exited, ...E
May 31 08:44:37 server.imprentasanchez.tk kill[28971]: kill: cannot find process ""
May 31 08:44:37 server.imprentasanchez.tk systemd[1]: httpd.service: control process exite...1
May 31 08:44:37 server.imprentasanchez.tk systemd[1]: Failed to start The Apache HTTP Server.
May 31 08:44:37 server.imprentasanchez.tk systemd[1]: Unit httpd.service entered failed state.
May 31 08:44:37 server.imprentasanchez.tk systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@server conf]#
</code>```

Config file with suggested configuration:

```<code><VirtualHost *:80>
    ServerName MyProject
    ServerAlias imprentasanchez.tk www.imprentasanchez.tk
    DocumentRoot /var/www/html/imprenta/public
    <Directory  "/var/www/html/imprenta/public">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
    </Directory>
</VirtualHost>
</code>```

答:
It seems you have issue at your server configuration end.

Update your httpd file to point /public directory of your project.

Here you can find the updated httpd.config file.

```<code>#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin root@localhost

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory /var/www/laravel/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html/imprenta/public/"

#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
    Require all denied
</Files>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error_log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    #CustomLog "logs/access_log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to
    # exist in your server's namespace, but do not anymore. The client
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig /etc/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default.  To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    #
    # The mod_mime_magic module allows the server to use various hints from the
    # contents of the file itself to determine its type.  The MIMEMagicFile
    # directive tells the module where the hint definitions are located.
    #
    MIMEMagicFile conf/magic
</IfModule>

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults if commented: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile on

# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf

<VirtualHost *:80>
    ServerName imprentasanchez.tk
    ServerAlias imprentasanchez.tk www.imprentasanchez.tk
    DocumentRoot "/var/www/html/imprenta/public"

    <Directory  "/var/www/html/imprenta/public">
        Options Indexes MultiViews FollowSymLinks
            AllowOverride All
            Order allow, deny
            Allow from all
    </Directory>
</VirtualHost>
</code>```

Once updated, don't forget to restart the server.

service httpd restart

Body:
So I have a project in Laravel in which I use Ajax to move between views, so no data, only GET request.

This works fine on my local machine but I uploaded it to my VPS and when I click the button that should take me to another view, I get this error:

GET http://172.106.202.124/trabajos?_=1559303733962 404 (Not Found)

So I've done some research and found some people with the same issue, but I haven't found any working answer.

Some said to modify .htaccess, I already did that and it's the same for me.

I've noticed that if I write /index.php/trabajos in the URL it gives me 'trabajos' view, but if I remove the /index.php/ it just gives me 'Not found'

This is my js code:

 $(document).on('click', '#button1', function() {
        $.ajax({
                method: "GET",
                url:'/trabajos',
                success:function(result) {

                        $("#app").html(result).hide().fadeIn(1200);
                },
                error : function(e){
                        console.info("Error");
                }
                });
        });

And these are my routes:

Route::get('/', function () {
    return view('master');
});
Route::get('/main', function () {
    return view('main');
});
Route::get('/trabajos', function(){
    return view('menu.trabajos');
});
Route::get('/contacto', function(){
    return view('menu.contacto');
});
Route::get('/empresa', function(){
    return view('menu.empresa');
});

This is my httpd config:

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin root@localhost

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory /var/www/laravel/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html/imprenta/public/"

#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
    Require all denied
</Files>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error_log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    #CustomLog "logs/access_log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to
    # exist in your server's namespace, but do not anymore. The client
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig /etc/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default.  To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    #
    # The mod_mime_magic module allows the server to use various hints from the
    # contents of the file itself to determine its type.  The MIMEMagicFile
    # directive tells the module where the hint definitions are located.
    #
    MIMEMagicFile conf/magic
</IfModule>

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults if commented: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile on

# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf

I get this error with the config:

* httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2019-05-31 08:44:37 EDT; 24s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 28971 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 28969 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 28969 (code=exited, status=1/FAILURE)

May 31 08:44:37 server.imprentasanchez.tk systemd[1]: Starting The Apache HTTP Server...
May 31 08:44:37 server.imprentasanchez.tk httpd[28969]: AH00534: httpd: Configuration erro....
May 31 08:44:37 server.imprentasanchez.tk systemd[1]: httpd.service: main process exited, ...E
May 31 08:44:37 server.imprentasanchez.tk kill[28971]: kill: cannot find process ""
May 31 08:44:37 server.imprentasanchez.tk systemd[1]: httpd.service: control process exite...1
May 31 08:44:37 server.imprentasanchez.tk systemd[1]: Failed to start The Apache HTTP Server.
May 31 08:44:37 server.imprentasanchez.tk systemd[1]: Unit httpd.service entered failed state.
May 31 08:44:37 server.imprentasanchez.tk systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@server conf]#

Config file with suggested configuration:

<VirtualHost *:80>
    ServerName MyProject
    ServerAlias imprentasanchez.tk www.imprentasanchez.tk
    DocumentRoot /var/www/html/imprenta/public
    <Directory  "/var/www/html/imprenta/public">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
    </Directory>
</VirtualHost>

Body:
It seems you have issue at your server configuration end.

Update your httpd file to point /public directory of your project.

Here you can find the updated httpd.config file.

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin root@localhost

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory /var/www/laravel/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html/imprenta/public/"

#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
    Require all denied
</Files>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error_log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    #CustomLog "logs/access_log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to
    # exist in your server's namespace, but do not anymore. The client
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig /etc/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default.  To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    #
    # The mod_mime_magic module allows the server to use various hints from the
    # contents of the file itself to determine its type.  The MIMEMagicFile
    # directive tells the module where the hint definitions are located.
    #
    MIMEMagicFile conf/magic
</IfModule>

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults if commented: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile on

# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf

<VirtualHost *:80>
    ServerName imprentasanchez.tk
    ServerAlias imprentasanchez.tk www.imprentasanchez.tk
    DocumentRoot "/var/www/html/imprenta/public"

    <Directory  "/var/www/html/imprenta/public">
        Options Indexes MultiViews FollowSymLinks
            AllowOverride All
            Order allow, deny
            Allow from all
    </Directory>
</VirtualHost>

Once updated, don't forget to restart the server.

service httpd restart


问:
How do i remove characters in a string between two specific characters?
I want to strip all characters in my string between "_" and " "

i've tried the split command but it takes everything after my parameter. I can't make it stop at " "

```<code>string = "adamannaogfrida_dfexosnfzg PeterMadsen_deinow_pk HjaltedDrejer_Weonfiweg"
</code>```

Expected output: adamannaogfrida PeterMadsen HjaltedDrejer

答:
Here's a regular expression approach:</p>

```<code>re.sub(r'_.+?\b', '', 'adamannaogfrida_dfexosnfzg PeterMadsen_deinow_pk HjaltedDrejer_Weonfiweg')
#'adamannaogfrida PeterMadsen HjaltedDrejer'
</code>```

Body:
I want to strip all characters in my string between "_" and " "

i've tried the split command but it takes everything after my parameter. I can't make it stop at " "

string = "adamannaogfrida_dfexosnfzg PeterMadsen_deinow_pk HjaltedDrejer_Weonfiweg"

Expected output: adamannaogfrida PeterMadsen HjaltedDrejer

Body:
Here's a regular expression approach:

re.sub(r'_.+?\b', '', 'adamannaogfrida_dfexosnfzg PeterMadsen_deinow_pk HjaltedDrejer_Weonfiweg')
#'adamannaogfrida PeterMadsen HjaltedDrejer'


问:
Setting Environment Variable ends with "-bash: !": event not found"
I am setting up a typical email function for firebase to alert me when a new record is added.  In my terminal, I am inputting the following:

```<code>firebase functions:config:set gmail.email="MyEmail@gmail.com" gmail.password="MyPassword1!"
</code>```

This returns the error:  -bash: !": event not found

I CAN set just the email if i want and it works fine, but setting the password gets me this issue.  So, this works:

```<code>firebase functions:config:set gmail.email="MyEmail@gmail.com"
</code>```

This does not:

```<code>firebase functions:config:set gmail.email="MyEmail@gmail.com" gmail.password="MyPassword1!"
</code>```

or

```<code>firebase functions:config:set gmail.password="MyPassword1!"
</code>```

Thoughts??

I would expect this to work and in fact i previously had it working.

答:
You got an error message because ! character in your password is expanded by bash (you are using double quotes). Try simple quotes instead :

```<code>firebase functions:config:set \
    gmail.email="MyEmail@gmail.com" \
    gmail.password='MyPassword1!'
</code>```

See also this question for reference.

Body:
I am setting up a typical email function for firebase to alert me when a new record is added.  In my terminal, I am inputting the following:

firebase functions:config:set gmail.email="MyEmail@gmail.com" gmail.password="MyPassword1!"

This returns the error:  -bash: !": event not found

I CAN set just the email if i want and it works fine, but setting the password gets me this issue.  So, this works:

firebase functions:config:set gmail.email="MyEmail@gmail.com"

This does not:

firebase functions:config:set gmail.email="MyEmail@gmail.com" gmail.password="MyPassword1!"

or

firebase functions:config:set gmail.password="MyPassword1!"

Thoughts??

I would expect this to work and in fact i previously had it working.

Body:
You got an error message because ! character in your password is expanded by bash (you are using double quotes). Try simple quotes instead :

firebase functions:config:set \
    gmail.email="MyEmail@gmail.com" \
    gmail.password='MyPassword1!'

See also this question for reference.


问:
CSS media query looks good locally but not when hosted online
Locally my banner-home2.png looks as I need it.

However, when uploaded it's size gets bigger. (I'm hosting this on heroku, but the css file is on Amazon).

And I can see that in these Codepen, it also look wrong (bigger than it should be):

Online version:

stickersgallito.pe:

Local version (correct size):

Codepen: https://codepen.io/anon/pen/EzOONJ

These are my media queries on Amazon:

```<code><link rel="stylesheet" href="https://stickers-gallito-uploaded-files.s3.amazonaws.com/static/css/home.css">
</code>```

home.css (media queries):

```<code>.my_header_bg_color {

    /*background-color: #4FB99F;*/
    /*background-color: #00ADB5;*/
    /*background-color: #6BB983;*/
    background-color: #00AD80;
}

/* standard media queries breakpoints */

@media (min-width: 320px) and (max-width: 480px) {
    /* smartphones, iPhone, portrait 480x320 phones */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .productos_finales_home img {

        padding-bottom: 15px;
    }

    .my_home_banner_image {
        bottom: 0;
        top: 0;
        position: relative;
        z-index: 0;
        width: 60%;
        display: block;
        margin-right: auto;
        margin-left: 165px;
    }

    /*.my_home_banner_image {*/
    /*display: none;*/
    /*}*/
    .my_home_banner_title {
        color: white;
        font-size: 36px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        text-decoration: none;
        background-color: #969696;
        display: inline-block;
        text-align: center;
        vertical-align: middle;
        cursor: pointer;
        color: #fff;
        font-weight: 700;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
        letter-spacing: 0;
        line-height: 1.2;
        -webkit-font-smoothing: antialiased;
        -webkit-box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
        -ms-box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
        -moz-box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
        -o-box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
        box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
        background-image: linear-gradient(to bottom, rgba(255, 255, 255, .09) 0%, rgba(0, 0, 0, .09) 100%);
        font-size: 1.4rem;
        padding: 22px 30px;
        border-radius: 6px;
        border: none;
    }

.my_home_banner_left {
    margin-left: 10px;
    z-index: 100;
}

.stickers_referenciales {
    margin-bottom: 5px;
}

}

@media (min-width: 481px) {
    /* portrait e-readers (Nook/Kindle), smaller tablets @ 600 or @ 640 wide. */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .my_home_banner_image {

        bottom: 0;
        position: absolute;
        right: -0px;
        bottom: 0;
        z-index: 0;
        width: 40%;
        display: block;
        margin-right: auto;
        margin-left: 185px;
    }

    .my_home_banner_title {
        color: white;
        font-size: 50px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        margin-bottom: 100px;
    }

    .my_home_banner_left {
        margin-left: 20px;
        z-index: 100;
    }

}

@media (min-width: 641px) {
    /* portrait tablets, portrait iPad, landscape e-readers, landscape 800x480 or 854x480 phones */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .my_home_banner_image {

        bottom: 0;
        position: absolute;
        right: -0px;
        bottom: 0;
        z-index: 0;
        width: 70%;
    }

    .my_home_banner_title {
        color: white;
        font-size: 50px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        margin-bottom: 100px;
    }

    .my_home_banner_left {
        margin-left: 20px;
        z-index: 100;
    }

    .my_home_banner_lef_text {
        margin-left: 10px;
        z-index: 100;
    }

}

@media (min-width: 961px) {
    /* tablet, landscape iPad, lo-res laptops ands desktops */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .my_home_banner_image {

        bottom: 0;
        position: absolute;
        right: -0px;
        bottom: 0;
        z-index: 0;
        width: 60%;
    }

    .my_home_banner_title {
        color: white;
        font-size: 50px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        margin-bottom: 100px;
    }

    .my_home_banner_left {
        margin-left: 20px;
        z-index: 100;
    }

}

@media (min-width: 1025px) {
    /* big landscape tablets, laptops, and desktops */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .my_home_banner_image {

        bottom: 0;
        position: absolute;
        right: -0px;
        bottom: 0;
        z-index: 0;
        width: 55%;
    }

    .my_home_banner_title {
        color: white;
        font-size: 50px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        margin-bottom: 100px;
    }

    .my_home_banner_left {
        margin-left: 20px;
        z-index: 100;
    }

    .subscribe_field {
        width: 350px;
    }

}

@media (min-width: 1281px) {
    /* hi-res laptops and desktops */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .my_home_banner_image {

        bottom: 0;
        position: absolute;
        right: -0px;
        bottom: 0;
        z-index: 0;
        width: 70%;
    }

    /*.my_home_banner_image_left {*/
    /*display: none;*/
    /*}*/
    .my_home_banner_title {
        color: white;
        font-size: 50px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        margin-bottom: 100px;
    }

    .my_home_banner_left {
        margin-left: 20px;
        z-index: 100;
    }

    .subscribe_field {
        width: 350px;
    }
}

.center-video {
    margin: 0 auto;
    width: 400px;
}
</code>```

答:
Inside home.css Line no 296

```<code>@media (min-width: 1281px)
.my_home_banner_image {
bottom: 0;
position: absolute;
right: 0;
bottom: 0;
z-index: 0;
width: 40%;
}
</code>```

Maybe it occurs because of server-side HTML, CSS or any other language version is different than in localhost we have. But you can set that thing as I gave above for more than 1281 screen size.

Body:
Locally my banner-home2.png looks as I need it.

However, when uploaded it's size gets bigger. (I'm hosting this on heroku, but the css file is on Amazon).

And I can see that in these Codepen, it also look wrong (bigger than it should be):

Online version:

stickersgallito.pe:

Local version (correct size):

Codepen: https://codepen.io/anon/pen/EzOONJ

These are my media queries on Amazon:

<link rel="stylesheet" href="https://stickers-gallito-uploaded-files.s3.amazonaws.com/static/css/home.css">

home.css (media queries):

.my_header_bg_color {

    /*background-color: #4FB99F;*/
    /*background-color: #00ADB5;*/
    /*background-color: #6BB983;*/
    background-color: #00AD80;
}

/* standard media queries breakpoints */

@media (min-width: 320px) and (max-width: 480px) {
    /* smartphones, iPhone, portrait 480x320 phones */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .productos_finales_home img {

        padding-bottom: 15px;
    }

    .my_home_banner_image {
        bottom: 0;
        top: 0;
        position: relative;
        z-index: 0;
        width: 60%;
        display: block;
        margin-right: auto;
        margin-left: 165px;
    }

    /*.my_home_banner_image {*/
    /*display: none;*/
    /*}*/
    .my_home_banner_title {
        color: white;
        font-size: 36px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        text-decoration: none;
        background-color: #969696;
        display: inline-block;
        text-align: center;
        vertical-align: middle;
        cursor: pointer;
        color: #fff;
        font-weight: 700;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
        letter-spacing: 0;
        line-height: 1.2;
        -webkit-font-smoothing: antialiased;
        -webkit-box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
        -ms-box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
        -moz-box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
        -o-box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
        box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
        background-image: linear-gradient(to bottom, rgba(255, 255, 255, .09) 0%, rgba(0, 0, 0, .09) 100%);
        font-size: 1.4rem;
        padding: 22px 30px;
        border-radius: 6px;
        border: none;
    }

.my_home_banner_left {
    margin-left: 10px;
    z-index: 100;
}

.stickers_referenciales {
    margin-bottom: 5px;
}

}

@media (min-width: 481px) {
    /* portrait e-readers (Nook/Kindle), smaller tablets @ 600 or @ 640 wide. */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .my_home_banner_image {

        bottom: 0;
        position: absolute;
        right: -0px;
        bottom: 0;
        z-index: 0;
        width: 40%;
        display: block;
        margin-right: auto;
        margin-left: 185px;
    }

    .my_home_banner_title {
        color: white;
        font-size: 50px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        margin-bottom: 100px;
    }

    .my_home_banner_left {
        margin-left: 20px;
        z-index: 100;
    }

}

@media (min-width: 641px) {
    /* portrait tablets, portrait iPad, landscape e-readers, landscape 800x480 or 854x480 phones */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .my_home_banner_image {

        bottom: 0;
        position: absolute;
        right: -0px;
        bottom: 0;
        z-index: 0;
        width: 70%;
    }

    .my_home_banner_title {
        color: white;
        font-size: 50px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        margin-bottom: 100px;
    }

    .my_home_banner_left {
        margin-left: 20px;
        z-index: 100;
    }

    .my_home_banner_lef_text {
        margin-left: 10px;
        z-index: 100;
    }

}

@media (min-width: 961px) {
    /* tablet, landscape iPad, lo-res laptops ands desktops */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .my_home_banner_image {

        bottom: 0;
        position: absolute;
        right: -0px;
        bottom: 0;
        z-index: 0;
        width: 60%;
    }

    .my_home_banner_title {
        color: white;
        font-size: 50px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        margin-bottom: 100px;
    }

    .my_home_banner_left {
        margin-left: 20px;
        z-index: 100;
    }

}

@media (min-width: 1025px) {
    /* big landscape tablets, laptops, and desktops */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .my_home_banner_image {

        bottom: 0;
        position: absolute;
        right: -0px;
        bottom: 0;
        z-index: 0;
        width: 55%;
    }

    .my_home_banner_title {
        color: white;
        font-size: 50px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        margin-bottom: 100px;
    }

    .my_home_banner_left {
        margin-left: 20px;
        z-index: 100;
    }

    .subscribe_field {
        width: 350px;
    }

}

@media (min-width: 1281px) {
    /* hi-res laptops and desktops */
    .my_home_banner {
        bottom: 0;
        margin-right: 8%;
        z-index: -600;
    }

    .my_home_banner_image {

        bottom: 0;
        position: absolute;
        right: -0px;
        bottom: 0;
        z-index: 0;
        width: 70%;
    }

    /*.my_home_banner_image_left {*/
    /*display: none;*/
    /*}*/
    .my_home_banner_title {
        color: white;
        font-size: 50px;
        font-weight: bold;
    }

    .my_home_banner_subtitle {
        margin-top: 0%;
        padding-top: 0%;
    }

    .btn, h2, p {
        margin-bottom: 10px;
    }

    .btn-comentario {
        margin-bottom: 100px;
    }

    .my_home_banner_left {
        margin-left: 20px;
        z-index: 100;
    }

    .subscribe_field {
        width: 350px;
    }
}

.center-video {
    margin: 0 auto;
    width: 400px;
}

Body:
Inside home.css Line no 296

@media (min-width: 1281px)
.my_home_banner_image {
bottom: 0;
position: absolute;
right: 0;
bottom: 0;
z-index: 0;
width: 40%;
}

Maybe it occurs because of server-side HTML, CSS or any other language version is different than in localhost we have. But you can set that thing as I gave above for more than 1281 screen size.