Configure base url Symfony2 for deployed project - .htaccess

I have deployed a Symfony2 project onto a server. I have added a .htaccess file in the project folder to automatically access the /web/app.php file.
Here is the .htaccess file I have added:
<IfModule mod_rewrite.c>
RewriteEngine On
<IfModule mod_vhost_alias.c>
RewriteBase /booking/itinerary/
</IfModule>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/app.php [QSA,L]
</IfModule>
The problem I have is that I cannot set up the base url for routing as being /booking/itinerary. I get the following error from symfony:
No route found for "GET /booking/itinerary/"
Although the 'booking/itinerary' should route to the 'homepage' with the pattern '/'.
How can I fix this? 'Cause it would be a pain to change all the routes in the project.

Related

htaccess symfony2 redirect to web directory

I've just published my symfony proyect, but the url is http://url.com/web/. I want to change my .htaccess to point to web directory. So, the url I want it to be like http://url.com/. I've tried to change my .htaccess but I have not been successful.
my project is in a shared host and i can't create a virtual host. I used this .htaccess file in symfony root and works.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Explicitly disable rewriting for front controllers
RewriteRule ^/web/app_dev.php - [L]
RewriteRule ^/web/app.php - [L]
# Fix the bundles folder
RewriteRule ^bundles/(.*)$ /web/bundles/$1 [QSA,L]
# Fix the assets folder
RewriteRule ^assets/(.*)$ /web/assets/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
# Change below before deploying to production
#RewriteRule ^(.*)$ /web/app.php [QSA,L]
RewriteRule ^(.*)$ /web/app_dev.php [QSA,L]
</IfModule>
https://undebugable.wordpress.com/2014/11/12/symfony2-htaccess-to-redirect-request-from-web-to/
Please read that page and look the Apache configurations.
http://symfony.com/doc/current/setup/web_server_configuration.html

Laravel 4 Internal Server Error 500 on Hostgator

I have a Laravel 4 app deployed on shared Hostgator server.
When I navigate to:
http://mydomain.com/laravel/public/
I can see the Laravel splash screen.
but when I try to access any other route to, say, /users or /posts I am getting
Internal Server Error 500
http://mydomain.com/laravel/public/posts
Controller:
public function index()
{
$posts = $this->post->all();
return View::make('posts.index', compact('posts'));
}
In Routes.php:
Route::resource('posts', 'PostsController');
I use Jeffrey Way's Generator to scaffold the posts entity.
The same works fine on my local machine. Controllers don't contain any logic, they only output the fetched data.
Error logs are empty.
Any ideas what to check? .htaccess, maybe?
Here is what I have there:
AddType application/x-httpd-php53 .php
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
As mentioned in comments, a 500 error without a corresponding log file entry from the application logger is likely an .htaccess file issue.
Since the OP found the issue is related to the rewrite (and not the directive to use php 5.3):
Since this is probably a common issue on Hostgator, you should check with their help docs.
However, my first stab at a fix would be to add a RewriteBase directive:
RewriteBase /
So it would look like:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Note that this assumes you're running the web application form the web root and not a sub-directory.

fuelphp htaccess for multiple app directory not working

I have a directory structure like below.
public_html/
/abc/
/xyz/
/pqr/
there is a index.php in each these directories, abc,xyz,pqr.
now whenever is there any request like domain.com/abc/def/ghi should be rewritten to domain.com/abc/index.php/def/ghi
domain.com/xyz/def/ghi => domain.com/xyz/index.php/def/ghi
domain.com/pqr/def/ghi => domain.com/pqr/index.php/def/ghi
What should be the .htaccess file and where it should be placed?
I have .htaccess file in each directory(abc,xyz,pqr) like below, but it is not working. it is showing 404 page not found. Please guide me to handle all these rewrite conditions.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
But this is not working... If this is right .htaccess then please tell me if there is any other server side problem. I am setting up this on CentOs server.
You will probably need a RewriteBase /abc to deal with the subfolders.
I had problem with my directory access, I was needed to update the access for content directory(domain.com) in apache config file(httpd.conf)

How to change.htaccess to allow access to multiple pages

I took over a hosting account for a friend to host a second domain on his server. All is good, except for the .htaccess file that was generated by whoever designed his first site.
The main site is: ra-pictures.com, hosted in the root folder /
The site I'm working on is posthumanmovie.com, which is hosted in the folder /posthuman
Here's the current .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
# route non-existant requests to single script
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteRule ^.*$ index.php [QSA,NS]
</IfModule>
When I try to go to posthumanmovie.com - I get a 404 not found error.
When I delete the .htaccess file, it works, but his other site ra-pictures.com has 404 errors on any page that isn't the index page. Any ideas on how I can change the .htaccess file to allow access to all pages from both sites?
Add a condition to check against the hostname:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ra-pictures\.com$ [NC]
# route non-existant requests to single script
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteRule ^.*$ index.php [QSA,NS]
</IfModule>

symfony2 on shared hosting

I've been working on this for quite a while to no avail.. I've got symfony installed on a shared web-host where I have zero access to change the DocumentRoot to the web/ folder so that is not an option to me...
I've written my htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^$ web/app.php [QSA]
RewriteRule ^(.*)$ web/app.php/$1 [QSA, L]
I have also tried this with RewriteBase web/ and RewriteBase /web/ to no avail.
With this, symfony is working.. I can login, I can do all of that... Only problem is, none of the assets are displaying... Chrome Developer Tools, is telling me it's finding a 404 which is right because it's not reading the /web/ folder as the DocumentRoot..
So, how to fix this issue without re-writing files, or anything.. There's got to be a way to do this with .htaccess only...
One way would be setting assets_base_urls in app/config.yml e.g
framework:
#..
templating:
engines: ['twig']
assets_base_urls: http://your.site.com/web/
Or, you can put a .htaccess file in your DocumentRoot folder and rewrite everything that comes in there to your /web folder accordingly:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /web/$1 [QSA,L]
</IfModule>
With that you get clean URL's (omitting "web" or "app.php") and there is no need to use the assets_base_urls stuff in your config.

Resources