0

I am new to Symfony with shared hosting.

Installed a symfony using Cpanel app installer option and made a page called about and its working like www.domain.com/symfony/web/app_dev.php/about but i want to know how to make that like following www.domain.com/symfony/about How do that possible?

i wrote .htaccess like below but no success,

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /symfony/web/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app_dev.php [QSA,L]
</IfModule>
Raha MK
  • 102
  • 3
  • 16
  • What happens if you delete your .htaccess, and try to go to www.domain.com/symfony/about? Do you have SSH access? – Matko Đipalo Nov 27 '16 at 11:54
  • i am getting "Internal Server Error" and SSH access yes and what i do through that? – Raha MK Nov 27 '16 at 12:09
  • I think you can find solution here: http://stackoverflow.com/questions/31426989/how-can-i-deploy-symfony-in-a-subdirectory Extra info: http://symfony.com/doc/current/configuration/override_dir_structure.html#override-the-web-directory – Matko Đipalo Nov 27 '16 at 12:20

2 Answers2

1

I'm assuming you're using Apache on the shared hosting (it's the most common).

The problem here is that your document root for your site is set to the directory two levels above the app_dev.php file.

You should add a subdomain for your app that points to your symfony/web folder as the root. You can find documentation on configuring subdomains in cPanel. Once that's running you should hopefully be able to access your app at symfony.yourdomain.com

mickadoo
  • 3,337
  • 1
  • 25
  • 38
  • i tried your way by adding addon domain and its working around 50% need but another page should work like www.domain.com/about now its coming like www.domain.com/app_dev.php/about – Raha MK Nov 29 '16 at 15:50
  • Updated with following .htaccess but no use ` RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ web/$1 [QSA,L] ` – Raha MK Nov 30 '16 at 18:17
  • I think your rewrite rules needs to point to app_dev.php check the default symfony one – mickadoo Nov 30 '16 at 19:27
  • Sorry, can't understand. and there is no .htaccess file default. – Raha MK Dec 01 '16 at 21:21
  • [here](https://github.com/symfony/symfony-standard/blob/master/web/.htaccess) is the default Symfony .htaccess file – mickadoo Dec 02 '16 at 12:20
  • Ok, In this file where i can set redirection ? – Raha MK Dec 03 '16 at 08:25
  • I thought your problem now was just app_dev.php appearing in the URL. The default .htaccess file should fix this if you put it in your web folder – mickadoo Dec 03 '16 at 10:58
  • I have done included .htaccess in the web/ folder but nothing happen its till same. – Raha MK Dec 03 '16 at 11:33
0

Using default .htaccess, you should be able to reach www.domain.com/symfony/web/about

To override the web directory, you can use this .htaccess on your base dir (same level with composer.json, etc)

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ web/$1 [QSA,L] 
</IfModule> 

Also, you want to make sure that mod_rewrite is enable on your PHP conf.

Bart Bartoman
  • 756
  • 4
  • 14
  • Where the .htacess file show be ? www.domain.com/symfony/.htaccess ? – Raha MK Nov 28 '16 at 12:45
  • Yes, exactly. Default .htaccess provided by Symfony work for everything except the base /web/ override, since it may change, depending on your web hosting – Bart Bartoman Nov 29 '16 at 08:13
  • i tried but no success, i am seeing 404 when i view www.domain.com/symfony and working when i see www.domain.com/symfony/web – Raha MK Nov 29 '16 at 12:56