Symfony .htaccess - troubleshooting 500 error on third level domain

My application is located in a subdirectory at www.example.com/application/v1 and I have a third-level domain set up at v1.example.com. I am using Symfony2 and this is the content of my .htaccess:

DirectoryIndex app.php

<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]

    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]

    RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 302 ^/$ /app.php/
    </IfModule>
</IfModule>

This is what my app.php contains:

 <?php

use Symfony\Component\HttpFoundation\Request;

require __DIR__.'/../app/autoload.php';
include_once __DIR__.'/../app/bootstrap.php.cache';

require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('prod', true);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);

// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

Everything works fine at www.example.com/application/v1, but I get a 500 error when trying v1.example.com. I contacted my hosting support and they suggested that the issue lies within my .htaccess file. How can I fix this?

Update: Should I update the rewrite condition in my .htaccess file?

Answer №1

To solve this issue, I have re-added the redirect to the third domain level. Here is how it looks:

 #redirect for service
    RewriteCond %{HTTPS_HOST} ^v1\.example\.com
    RewriteRule ^(.*)$ /application/v1/$1 [L]

I realized that I needed to redirect all requests under my project, not just the root directory.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Steps for clearing cache and resetting a Guzzle client to free up memory usage:

I am currently facing an issue with my code, which involves making multiple calls to the same site using Guzzle in order to check for the existence of a document. Each call results in an increase in memory usage, eventually leading to memory exhaustion whe ...

Missing categories on the main page

Recently, I began exploring Magento. After adding a new Category from the admin panel and setting 'Include in navigation menu' to yes, I added new products to the Category. Even after adjusting the quantity in stock, ensuring stock availability i ...

Encountering a problematic scenario after transitioning from PHP 5 to PHP 7, where a previously functional dynamic

I am in the process of repairing a website that I own which is currently not functioning. After careful examination, I have identified the issue in the following code: <?php global $options; foreach ( $options as $value ) { if ( isset( $value[' ...

producing a unified outcome array by merging the results of two queries

I am trying to retrieve a single result response by combining two separate queries that are currently working independently. Is there a way to write a single query that can merge the functionality of both my existing queries? The first query looks like th ...

What is the process for transforming the search bar into an icon located at the top of a WordPress site?

For the past few weeks, I've been attempting to convert the search bar on my website (which is currently a plugin) into an icon positioned near the header. I've experimented with modifying the child theme's functions.php, the parent theme&a ...

Deploying PHP applications using CodeDeploy with persistent sessions

We have a unique setup with our PHP application running on an AWS auto-scale group utilizing sticky sessions behind an AWS ELB. During a CodeDeploy release, the existing files are first deleted before being replaced with new ones. This process causes web ...

Is there a way for me to automatically go back to the home page when I press the back button on the browser?

My ecommerce website has a shopping cart page where customers can purchase products and make payments. After the payment is completed, they are directed to a thank you page. The flow of the website is as follows: Home page => Products => Shopping cart => ...

What is the best way to display div elements based on a selected option?

Here is the code for a select list that contains the number of guests for a room: <select name="txtHotelGuestNO" id="txtHotelGuestNO" class="hotels" onchange="show_room_choose()"> <?php for($i=1;$i<=100;$i++) echo "<option value=$i>$ ...

PHP isn't sending data (even though the name tag is defined)

After reviewing numerous posts where individuals forget to include the name attribute in their input tags, I came up with a simple script: <form action="submit_form.php" method="post"> Name: <input type="text" name="name"><br> ...

Warning: The username index is not defined in the file C:xampphtdocsindex.php at line 4

Hey there, I just wanted to express my gratitude for taking the time to read this. It's all part of a college assignment (web server scripting unit p4) where I am working on setting up a simple login system. Unfortunately, I keep running into an error ...

Change the lowercase character 'ß' to uppercase 'ẞ' within a PHP script

I'm wondering how to change the lowercase letter 'ß' to uppercase. I've attempted using the predefined functions strtoupper and mb_strtoupper, but here's what happened: When I tried strtoupper: echo strtoupper('ß'); // ...

Utilizing the Google Sheets API V4 to Append a Tab at the Start

I have successfully implemented the code below to create a new tab in my spreadsheet: $newSheetTitie = date("m/d/Y"); $body = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(array( 'requests' => array('addSheet' => ar ...

Retrieve data from the child window or obtain the uploaded file name

My issue involves a form that captures multiple entries and inserts them into a database via post data. This functionality works well. Additionally, I have a file upload form that effectively renames and moves files. However, my challenge lies in integrati ...

What steps do I need to take to integrate an Android app with an online MySQL database?

I am currently developing an Android app where users will input text, and I need to store that data in an online database for later retrieval. I have a LAMP server set up online that I can utilize. Could someone guide me on how to connect Java with PHP an ...

The Vuejs code functions properly in the overall application, but is not functioning within the specific component

Before, my Vue.js app worked flawlessly until I tried putting it into a Vue component. It started throwing the following error: [Vue warn]: Error compiling template. Here's the code for the component (components.php): <script> Vue.component(&ap ...

Using PHP to submit a file through an API

I'm currently working on creating an API endpoint to integrate with my Laravel and Vue application. public function avatar(Request $request) { $user = User::find(Auth::id()); $validator = Validator::make($request->all(), [ ...

Show a list of Active Directory groups that a user is a part of, including all nested memberships

This script I have checks for access in AD and verifies membership within a specific group. I am looking to list all groups that a user has access to, including indirect ones. For example - if userA is in groupA and groupA is in groupB, I want it to show ...

"Enhance your database by incorporating HTML link clicks through AJAX integration with PHP and MySQL

After browsing through similar questions and attempting to implement it on my website, I'm facing an issue where the expected functionality is not working as intended. When users click on a link, there is no response in the console, and the database r ...

Extract data using PHP regular expressions

I need to extract a specific portion of HTML data, removing everything above an H1 tag and below an H2 tag with the text 'What we offer'. This extracted data should be stored in a variable. <p>This part is unnecessary</p> <h1>T ...

Is there a way to invert the contains() function in Laravel?

As a beginner in Laravel, I am facing an issue. I need to retrieve a row from a table based on its Many-to-Many relationship with another table. Usually, we use the contain() method to pass multiple IDs and check if they have a relationship with the row o ...