I have a c-panel shared hosting. Now, the docroot for the sitename.com
resides at public_html
folder. Say, I have a symfony application installed in the same. So, the web folder for my symfony application is at public_html/symfony/web/
. If I want to try it, I should hit sitename.com/symfony/web/app_dev.php
.
Here's the tricky part: I am trying to use htaccess somehow to get sitename.com/hi
to invoke sitename.com/symfony/web/app_dev.php/hi
internally. The constraints are, I cannot modify my httpd-vhosts.conf
to update my hosting directory. It might not be a practical thought, still, would love to figure out this, just as some food for thoughts.
try this in your public_html
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [L]
Edit .htaccess
in public_html
folder and add rewrite
directives to pointing your request to wanted foder /symfony/web/
:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sitename.com$ [NC,OR]
RewriteCond %{REQUEST_URI} !symfony/web/
RewriteRule (.*) /symfony/web/$1 [L]
DirectoryIndex app.php
If you are using /symfony/web/app.php
as front controller don't forget to add directive DirectoryIndex
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.