Symfony 3.4 located in subdirecory, remove web/ from url - .htaccess

I have 3 php apps on one server. I cant modify any apache files. Haw can I set .htaccess to remove web/ folder from url?
192.168.45.54/app1/
192.168.45.54/app2/
192.168.45.54/app3/web - I want to change it to 192.168.45.54/app3/
On adress 192.168.45.54/app3/web/ everythink is working fine. But haw can I remove web/ from url?
I created .htaccess files:
RewriteEngine On
RewriteBase /app3
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [QSA,L]
But when I go to 192.168.45.54/app3/ in symfony log files I have fallowing error:
No route found for "GET /app3/"
I use Symfony in 3.4 version. I think that problem is in .htaccess located in /web directory... Haw to configure .htaccess corectly?
I can't create virtual host becouse I haven't access to the server...

You need to make the web/ directory the document root of your website. If you have direct access to the webserver’s virtual host configuration, change the document root to the following line and restart Apache:
DocumentRoot /path/to/symfony/web/
If you can’t modify the virtual host file directly, your hosting provider will usually give you the possibility to modify the document root through some kind of online tool.

Related

Azure Web App - Linux/Laravel : Point domain to folder

I just started using Azure and created a Linux web app.
I followed the domain DNS tutorial and setup my domain :
https://learn.microsoft.com/en-us/azure/app-service-web/app-service-web-tutorial-custom-domain
I used the custom domain - text type
test.com does not point to the folder /site/wwwroot on the app.
I placed the site folder in /wwwroot
However, in laravel - the actual site is in /sitefolder/public
How do I point to this folder?
Thanks
It has nothing to do with DNS. What you need to do is create a .htaccess file containing the following code and place this file in Laravel's root directory.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
More on this:
How can I remove "public/index.php" in the url generated laravel?
Apache rewrite for Laravel /public

.htaccess: hiding subdomain with proxy redirect / rewrite

I need to access my site that sits in a subfolder from my domain.
The challenge - Due to my hosting structure, all sites are on the master domain's server in subfolders. Domains are mapped to those folders for each site. The master domain, however, is mapped to the server root like this -
• /www/ (root of www.masterdomain.com)
/folder 1/ (root of www.site1.com)
/folder 2/ (root of www.site2.com)
/folder 3/ (root of www.site3.com)
/folder 4/ (desired root of master domain)
If i install my CMS in folder 4 everything is fine, BUT the CMS code creates new assets in the server root (using DOCUMENT_ROOT i think), NOT in the subfolder.
Attempted fix 1:
Use a rewrite to remove subfolder and set all paths to include subfolder.
Failed - CMS acts as desired, but assets still created in the root.
Attempted fix 2:
Map a subdomain to the folder and rewrite URL to remove subdomain.
Failed: CMS works on subdomain and creates assets in the subfolder (win!), but can't rewrite a subdomain.
Attempted fix 3:
Map a subdomain to the folder, and use a proxy flag from the main domain to load content from it invisibly.
Progress made! Main homepage displays with the correct URL, however linked files and subfolders do not work.
So i can now reach my web app from:
app.exampledomain.com (app works perfectly on all fronts)
OR
exampledomain.com (proxy in effect, all subfolders and links broken)
Here's my htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Proxy subfolders
RewriteRule ^exampledomain.com/(.+?)?$ http://app.exampledomain.com/$1 [P,L,NC]
# Proxy main
RewriteRule ^(exampledomain.com)?$ http://app.exampledomain.com/ [P,L,NC]
So why are my subfolders / assets not working? Problem with the .htaccess? Bad logic?
Important notes -
Subfolder pages are called index.php so can be accessed from -
/folder/
The broken links on the page are in this format -
js/foundation.min.js
Thanks.
RewriteRule knows nothing about domain names, it works only with a local path.
Instead, check the domain name in the RewriteCond:
RewriteCond %{HTTP_HOST} ^(www\.)*exampledomain\.com$ [NC]
RewriteRule (.*) http://httpd.apache.org/$1 [P,L]
But using mod_alias or VirtualHost would be a more correct decision here.

Setup website with / prefixed URLs to run in sub-directory

I am trying to host a website that is setup with links in the format /css/file.css and /js/file.js and I'd like to set it up in a sub-directory on an existing domain for demo purposes.
So
/demo/css/file.css is the true path
But the demo/index.php references
/css/file.css
I can have a custom .htaccess file within the sub-directory.
Is this possible without touching the main site on my domain?
If the request is for /css/file.css then rules have to be placed in root .htaccess not in /demo/ directory.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^((?:css|js)/.+)$ /demo/$1 [L,NC,R=302]

Laravel 4 Routing issue

i hope you can help me out as been scratching my head for ages..
I have the laravel 4 installed in a folder called 'myapp' www.example.com/myapp/
I'm calling this but i'm getting app undefined..
Route::get('login', function(){
//do something
});
The only way i can get it to work is this way, but it messes everything up all the styles etc..
Route::get('/myapp/login', function(){
//do something
});
And this is my current .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
Options -MultiViews
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Does anyone know how to get it to work just for the myapp folder?
Thanks in advance.
I've now figured this out.
I needed to change the .htaccess file from this
RewriteRule ^ index.php [L]
to this
RewriteRule ^ /myapp/index.php [L]
I think your web server might be misconfigured. A correct web server configuration usually requires no changes to .htaccess.
Normally, using Laravel, you should have a DocumentRoot directive that points the web server to the public directory of your Laravel installation.
Exactly how you do that varies a little among operating systems. On my system, which is a development system running Ubuntu Linux, and which hosts multiple Laravel projects, I use multiple virtual servers. Ubuntu's configurations for these virtual servers are stored in /etc/apache2/sites-enabled. The configuration file for my calendar project (locally, calendar.dev) looks like this.
$ cat /etc/apache2/sites-enabled/calendar.dev
<VirtualHost *:80>
ServerName calendar.dev
ServerAlias calendar.dev *.calendar.dev
DocumentRoot "/var/www/calendar/public"
HostNameLookups double
</VirtualHost>%
If you're using "myapp" in place of the default "public" folder, then your DocumentRoot directive should point to "myapp" instead of "public".
If you're using "myapp" in place of the default "app" directory, you need to back up and rethink this. The "app" directory shouldn't be accessible to web users.
I agree completely with Mike Sherrill. Laravel ships with .htaccess config file that works "out of the box". There was some problems with older Laravel versions, but with L4 no. If you plan to add new virtual host don't forget to register one in /etc/hosts file. So check your server configuration.

.htaccess file 404 error with parallel plesk server

I have my .htaccess file working in localhost. But its not working if i upload it in server. It throws me 404 error.
I am using Parallel Plesk 11.0.9 and i can't find conf file for the same on that. If anyone has any idea how to fix it or any workaround for url rewriting would be great help.
Anyway here's the code in htaccess:
RewriteEngine on
RewriteRule ^store/living/Hutches-Armoires-Side-tables-Coffee-tables-Entertainment-centers? store.php?store=Living
RewriteRule ^store/dining/sideboards-buffets-chairs-benches-Dining-table$ store.php?store=Dining
RewriteRule ^store/working/Bookshelves-Study-tables$ store.php?store=Working
RewriteRule ^store/accessories/Boxes-Photo-Frames-Mirror-Frames-Block-Stamps-and-Book-stands$ store.php?store=Accessories
RewriteRule ^store/hallway/Console-tables-Armoires$ store.php?store=Hallway
RewriteRule ^store/sleeping/Bed-Frames-Night-Stands-Dressers-Mirror-framesBed-Linens-Canopies-Curtains$ store.php?store=Sleeping
You may need to wrap your rewrite rules with:
<IfModule mod_rewrite.c>
...
</IfModule>
...probably a good idea anyway.
Or you could try putting your rules into a vhost.conf file in the conf directory immediately below the location of your httpdocs directory. For example on a Centos machine the web root might be
/var/www/vhosts/domain.com/httpdocs
and you should have a:
/var/www/vhosts/domain.com/conf
directory, this will contain a set of pregenerated Apache config files that Plesk creates. If there isn't already create a vhost.conf and add your rules between a set of
<Directory /var/www/vhosts/domain.com/httpdocs/ >
... your rules ...
</Directory>
Once you've created the vhost.conf file you will need to tell plesk about it with
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain domain.com
If you still can't get it to work you can add a log for mod_rewrite, see this relevant SO answer for details
Is your Plesk running IIS and supporting PHP via FastCGI or ISAPI? If that is the case, check whether URL Rewrite is installed and follow this guide to translate htaccess (for apache) into web.config (for IIS)

Resources