I am running symfony2 in Windows7 and Xampp:
http://localhost/symfony/web/app_dev.php/hello/symfony
How do I change web/.htaccess file to access symfony using the link below?
http://localhost/app_dev.php/hello/symfony
the default .htaccess is:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
I tried adding Rewrite RewriteBase /symfony/web/ or RewriteBase symfony/web/ then php app/console cache:clear --env=prod --no-debug and also tried restarting apache.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
RewriteBase /symfony/web/ OR RewriteBase symfony/web/
And can I do the same in Nginx with Reverse proxy? How to change to access without symfony/web?
tried add 127.0.0.1 www.mysymfony.com.localhost
into etc/hosts
add the following into httpd.conf
# Be sure to only have this line once in your configuration<br>
NameVirtualHost 127.0.0.1:80
# This is the configuration for your project
Listen 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
ServerName www.mysymfony.com.localhost
DocumentRoot "D:\xampp\htdocs\symfony\web"
DirectoryIndex app.php
<Directory "D:\xampp\htdocs\symfony\web">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
access this link
http://www.mysymfony.com.localhost/app_dev.php/demo/hello/symfony
it gives an error,doesnt have this link
Related
This is mine route directory .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php/$1 [L]
the app is working only for home route i changed it from
$route['default_controller'] = 'home';
$route['default_controller'] = 'login';
but it is not working
You need to make sure rewrite_module is enabled on your server
sudo a2enmod rewrite
Then restart your apache
sudo systemctl restart apache2
Then add this to your config file under sites-available
<VirtualHost *:80>
<Directory /var/www/SITE_DIRECTORY>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
. . .
</VirtualHost>
Finally add RewriteEngine on to your .htaccess
I am using ubuntu 20, laravel project run using php artisan serve but when I access the site using this URL laravel-local.com it shows blank page
Could not get any error
sites-available
<VirtualHost *:80>
ServerAdmin admin#MyWebsite.com
DocumentRoot /var/www/html/laravel-local.com/public
ServerName laravel-local.com
<Directory /var/www/html/laravel-local.com/public>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What I tried
Give project 777 access
Change the ownership
Delete the folder inside the storage/framework
Change the storage folder permission
composer dump-autoload, php artisan cache and config clear
Delete .htaccess file in public folder
I tried all the above steps still got a blank page
.htaccess file in root folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
.htaccess in the public folder
<IfModule mod_rewrite.c>
Options -Indexes
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
sites-available
UPDATE: Your vHost config should be defined in "sites-enabled" for the config to actually be applied. Create a symlink from "sites-enabled" to the actual config file in "sites-available". And restart Apache.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
You don't need an .htaccess file like this (which would need to go in the directory above the /public directory) because you have already configured the /public directory as the DocumentRoot in the server config.
If you had also deleted the .htaccess file inside the /public subdirectory then this would have resulted in a rewrite-loop (500 error).
You just need the standard Laravel front-controller (.htaccess file) inside the document root, ie. in the /public subdirectory.
However, you should define the DirectoryIndex (if not already set somewhere in the server config), either in your vHost (<Directory> container) or at the top of your main Laravel .htaccess file (inside the /public folder). If this is not defined then requests to the Laravel directory itself (the homepage) will not be routed through Laravel and will likely result in a 403 Forbidden response (or worse, a directory listing if Indexes have been enabled) from Apache.
For example:
DirectoryIndex index.php
when I access the application from same computer where wampServer is installed every thing works fine whether I access it using localhost or Ip of the computer but when I put wamp server online and access the same app from another computer using the Ip of the computer where wamp is installed routes doesn't work for me only root page is being accessed and if I click on any other link I get 404 error
Here is .htaccess file in public folder
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteBase /laravel/itman/public/
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
httpd-vhosts.conf file in wamp\bin\apache\apache2.4.41\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
The apache virtual host should point to the public directory for your laravel project.
e.g.
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/public"
<Directory "${INSTALL_DIR}/www/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I have Laravel 6.4 installed on ubuntu 18.04 with php 7.2 and apache2. I have built a case study to develop an api and when I execute the php artisan serve command and use postman to do the query everything works fine. But if I create a virtualhost, I can see the website without problems, however, when executing a query through the postman I get the 404 error.
The .htaccess file is the one that brings by default laravel:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
and my virtualhost is the following:
<VirtualHost test-api.local:80>
ServerName test-api.local
DocumentRoot /var/www/html/restlav/public
DirectoryIndex index.php
ErrorLog ${APACHE_LOG_DIR}/test-api.local-error.log
CustomLog ${APACHE_LOG_DIR}/test-api.local-access.log combined
<Directory "/var/www/html/restlav">
Options +FollowSymLinks
RewriteEngine On
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
I have already tried to make the changes that are suggested in the official documentation and nothing. The rewrite module is enabled. If anyone could help me I appreciate it in advance.
In the <Directory> section you need to set AllowOverride to All:
<VirtualHost test-api.local:80>
ServerName test-api.local
DocumentRoot /var/www/html/restlav/public
DirectoryIndex index.php
ErrorLog ${APACHE_LOG_DIR}/test-api.local-error.log
CustomLog ${APACHE_LOG_DIR}/test-api.local-access.log combined
<Directory "/var/www/html/restlav">
Options +FollowSymLinks
RewriteEngine On
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Also make sure to enable the rewrite module in the apache server:
$ sudo a2enmod rewrite
And don't forget to finally restart the apache server to make the changes come into effect:
$ sudo systemctl restart apache2
Disclaimer - I'm a total newb when it comes to this. Inherited this issue.
I just installed the SSL certificate to our website. Install seems to have gone fine. Whenever I try to access a page via https I receive a 310 - Too many redirects error. I suspect this has something to do with how my virtual host is setup but I don't know enough about what I am looking at.
Here is the code from the SSL virtual host
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile "/path/file.crt"
SSLCertificateKeyFile "/path/file.key"
SSLCertificateChainFile "/path/file.crt"
ServerAdmin admins#email.com
ServerName domain.com
DocumentRoot /var/www/domain.com/www
<Directory /var/www/domain.com/www>
SSLRequireSSL
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^labs$ http://www.mdlabtests.com/ [L]
RewriteRule ^imaging$ http://prepaidimaging.com/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-zA-Z]*)$ /index.php?aid=$1 [L]
</Directory>
ErrorLog /path/file.log
TransferLog /path/file.log
LogLevel warn
Alias /comp /var/www/domain.com/www/comp.php
<Location /card>
DirectoryIndex create_card.php
</Location>
php_admin_value session.cookie_domain "domain.com"
php_admin_flag session.cookie_secure off
php_admin_value open_basedir "/var/www/domain.com/:/var/www/sub_dir/cg/:/usr/share/php/"
php_value include_path ".:/var/www/domain.com/includes:/usr/share/php"
php_admin_flag file_uploads off
The page I am trying to access is https://domain.com/enrollment.php
Any ideas?
Or do you have an .htaccess file lurking on your filesystem?