How to remove /public from url in Symfony5 subdir? - .htaccess

I have a project inside public_html/HELP
but the problem is to access /HELP I need to put /public
I tried various solution that I could find in internet but failed.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
please provide me solution where I can access /public with just example.com/HELP.
Thanks

Related

Cakephp project not working on server

Currently working on a project and completed. Works fine in local. But when uploaded to server. It Doesnt work as it should be. CSS and JS and images are not linked. I checked all the .htaccess files in project folder and they seem fine. These are the codes in .htaccess files
in root
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
in app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
in webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
These files were still same since uploaded to server. I also went through some articles and questions to make sure that am not messing with .htaccess files. Then i found this issue.
in local when i tried to open /localhost/project/app/Controller/UsersController.php in local it returns error as it should be
But when i tried the same in server
The page actually seems accessed. Since its controller no output is found but i can be sure the Controller is accessed directly. I cant figure out what kind of issue am going through. Am quite new to this. Any help will be appreciated.
Cake creates tmp files under tmp folder. You must need to give permission read/write to this folder. After making your code live please make 777 permission to your tmp folder and try to delete all those files under sub folders. It may work and please share your results. You will find tmp folder under app folder.
Your problem is in the in root .htaccess it should be like:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ projectfolder/app/webroot/ [L]
RewriteRule (.*) projectfolder/app/webroot/$1 [L]
</IfModule>
The project works now(Have to contact support for enabling the mod_rewrite). I enabled
Configure::write('App.baseUrl', env('SCRIPT_NAME'));
in config/core.php The problem is didnt have the mod_rewrite enabled in server. So enabling that in core supported the project to work without mod rewrite.
Thanks to
http://wwdj.wijndaele.com/getting-started-with-cakephp-without-mod_rewrite/
I had same problem, it was working on localhost but not on server, it was throwing 404 error.
It is because I had uploaded my website in subdirectory of sever root. I did many things to make it work but as I am using htaccess in root folder I found no solution on root level.
Finally I found a solution, edited existing htaccess of cakephp root folder and added "RewriteBase" after RewriteEngine on.
Full code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /name_of_the_subFolder
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Like if my project appear in 'xyz.com/one/two/cake/' then RewriteBase would be Rewritebase /one/two/cake/.
It worked for me.

.htaccess rules for Laravel installation

I am having trouble getting my Laravel installation to work on my local server. It has been pulled from a server where it was working correctly but now none of the links work and I can't seem t get them working.
My WAMP Laravel installation is in the folder WWW (root folder of local server)...
Here is the /htaccesss (as it comes from the live server:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /~celeb/index.php [L]
Now, I know I will have to remove the '~celeb' part in the Rewrite Rule but when I do this the links still do not work. For example, when I click on a link such as "****/signup" it doesn't work, but when I add 'index.php' into it ("*****/index.php/signup') it works fine.
Does anyone know why this is happening as it is driving me crazy!
Thanks
I had the same problem and adding the RewriteBase rule to the .htaccess file did solve it.
Example for url : localhost/example/index.php :
RewriteBase /example
Then restart apache and maybe it'll work :)
Bests,
Kevin

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)

Configure base url Symfony2 for deployed project

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.

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