i have created first Symfony application but the url is so large
http:// ip address/repair/web/app_dev.php/home
http:// ip address/repair/web/app.php/home
i want to make it as http:// ip address/repair/home
here is httpd.conf of apache2
NameVirtualHost something ip address
ServerName "repair"
DocumentRoot "/var/www/repair/web"
<Directory "/var/www/repair/web">
DirectoryIndex app.php
AllowOverride None
Order allow,deny
Allow from All
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
RedirectMatch permanent ^/app\.php/(.*) /$1
</Directory>
my .htaccess of in web folder of symfony contains
Options +FollowSymlinks
RewriteEngine On
# Explicitly disable rewriting for front controllers
RewriteRule ^app.php - [L]
RewriteRule ^app.php - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
i have reloded the mod-Rewrite of apache2 too
iam getting error
The requested URL /repair/home was not found on this server.
Apache/2.2.20 (Ubuntu) Server at ip address Port 80
If you want to access site by ip you need to copy your code to "localhost" directory (/var/www, e.g.)
The AllowOverride None line in your Apache config is causing the .htaccess file to be ignored.
If you replace it with AllowOverride All Apache will follow the directives in your .htaccess file.
You can find more information about AllowOverride here
Double-check that you actually have mod-rewrite loaded for Apache. On a Debian 6 install with Apache 2, the module was available, but it wasn't loaded. In order to load it, you can add a symlink in the mods-enabled directory to the module in the mods-available directory like this:
root#server:/etc/apache2/mods-enabled# ln -s ../mods-available/rewrite.load ./rewrite.load
Then you'll need to restart Apache2 to get it to reload its configuration. On Debian that would be sudo service apache2 restart
Related
I have a project that has a 'public' and 'private' folder structure that sit at the same level inside the main project root folder (see attached image).
I would like so that the local server (in this case MAMP) automatically defaults to the 'public' folder as the domain root. Is it best to do this is in php or in Apache?
Also, when I upload the site to a production server the domain name is going to be set on the 'public' folder, so I'd ideally like a solution that means I when I upload the site this will still be the case - i.e. www.example.com will be the 'project/public' folder.
This is all new to me so am at a bit of loss as to the best way to approach this.
Basically all you need is to create a virtual host configuration file and enable the port in Apache configuration file on which you're application is going to listen to the requests. I've never used MAMP so am giving you an example of vhost configuration on Linux machine
Create a conf file in /etc/httpd/conf.d/
vim /etc/httpd/conf.d/example.conf
This file will tell Apache server what will be the document root for
a specific port. PORT can be any available port other then reserved
Ports (0-1023)
<VirtualHost *:80>
KeepAlive On
DocumentRoot "/var/www/example/public"
<Directory "/var/www/example/public/">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride None
Order allow,deny
Allow from all
# enable mod_rewrite
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]
</Directory>
LogLevel Warn
ErrorLog /var/log/httpd/example-error.log
CustomLog /var/log/httpd/example-access.log combined
Add this Port No PORT in Apache conf file
(/etc/httpd/conf/httpd.conf)
Listen PORT
Restart Apache Server
Like XAMP & WAMP, MAMP should also have a GUI to configure the Apache Server. You can locate the location/folder where these vhost configuration are save and you can modify that file directly through any Text Editor
You can refer these too
Configuring Virtual Hosts With MAMP
Adding a virtual host in MAMP for Mac
I'm trying to run a php project using apache configurations in LAMP but its not working*, whereas when I run it as php -S locahost:4000 its working really great.
Here is the link to the project if you need some info about the files or working of it Project
Here is my apache configuration -
<VirtualHost localhost:4000>
ServerAdmin root#localhost
ServerName localhost
ServerAlias localhost
DocumentRoot /var/www/html/dir
<Directory "/var/www/html/dir">
AllowOverride None
Options None
Require all granted
</Directory>
*not working means - when running it through apache i can only access the index page and when going to some other page of the project like localhost:4000/about It shows The requested URL /department was not found on this server. ie. Error 404.
I think that you expect "index.php" to receive all requests.
Now, Apache is trying to find "about" directory and "department" directory.
In order for Apache to run index.php on any URL, we need to use the Rewrite rule.
Although I have not verified it in detail, I guess it will work with the following rules.
RewriteEngine on
RewriteRule ^/(.*)$ /index.php
It now working after enabling a2enmod rewrite from apache and updating the contents of .htaccess file as follows
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
I haVE my page hosted in Amazon EC2, it was working well in the root of the apache server (/var/www/html). But i want to have an other page in the same server so i start moving it to a subfolder (/var/www/html/alqip/public) so i can setup the second website in (/var/www/html/page2).
The site is developed in Laravel 5 and it is showing a blank page without login any error in laravel logs and system logs either (syslog, apache logs, php logs).
The permissions of storage folder are 777.
This is my .htaccess in public/ folder:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And my page.config in /var/apache2/sites-available:
<VirtualHost *:80>
ServerName alqip.com
ServerAlias www.alqip.com
DocumentRoot "/var/www/html/alqip/public"
<Directory "/var/www/html/alqip/public">
AllowOverride All
</Directory>
</VirtualHost>
I think the problem is in Laravel, not in server configuration, what do you think? Thanks!
Verify the firewall is down and if you are on centos check the configuration of the selinux. For default the selinux is enable edit the file /etc/selinux/config
SELINUX=disabled
After disbled you have to reboot you server
after installing Laravel you must create the .env file using the .envexample template.
the next problem you will have is permission issues
Its caused because php is running as another user by default.
so to fix this do
sudo nano /etc/php/7.0/fpm/pool.d/www.conf
then edit the
user = "put user that owns the directories" group = "put user that owns the directories"
then:
sudo systemctl reload php7.0-fpm
I can't configure routing project in Yii is 3 days, all tried to help ...
I have:
/var/www/ - project
/var/www/yii - yii framework
./htaccess
RewriteEngine On
# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is http://localhost/begin/, use /begin/
RewriteBase /
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
index.php finds.
./var/www/protected/config/main.php
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' => false,
'rules'=>array(
'/'=>'/view',
'//'=>'/',
'/'=>'/',
),
),
When I enter for example 107.170.91.28/site/contact then displays an error 404.
URL of server 107.170.91.28
On the local server. all works.
If I enter this URL 107.170.91.28/index.php/site/contact or 107.170.91.28/index.php?r=site/contact - it works.
Ask for help, because I tried all methods set.
If this is happening only on server it is either because you have configured Apache to ignore .htaccess directives on your server, or because you do not have Rewrite module loaded/installed
Either you can configure the apache conf to turn on by changing in /etc/apache2/apache2.conf (location may be different depending on OS , you can of course turn it only for application directory only as well
<Directory>
...
AllowOverride None
....
</Directory>
to
<Directory>
...
AllowOverride All
....
</Directory>
for enabling rewrite module you can do ( may vary depending on OS)
a2enmod rewrite
Restart apache2 after
/etc/init.d/apache2 restart
or
service apache2 restart
I'm running on an Ubuntu 13.10 dev environment with Apache2 and after hours of trying to figure out permission errors to access routes, I was able to fix it. Now I can successfully browse through my application, but the problem that now exists is that I cannot access my css/js files within my public directory - it kicks back with a 403.
I've tried modifying the .htaccess file, the virtual host config file, and ran chmod on the entire site directory.
Here's a copy of my .htaccess file within the Public folder:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
And here's a copy of my virtual host file:
<VirtualHost *:80>
DocumentRoot "/home/casey/Sites/caseyhoffmann.me/public"
ServerName caseyhoffmann.me.dev
<Directory "/home/casey/Sites/caseyhoffmann.me/public/">
AllowOverride all
Require all granted
DirectoryIndex index.php index.html
Options -MultiViews
</Directory>
</VirtualHost>
Any ideas?
Solved. Reapplied chown and redid chmod on the directory. File system permissions issue and had nothing to do with Apache.
Solution 1: (Recommended)
use absolute path in your css, js, images files rather than a relative one. Which means you have to make sure path of these files start either with http:// or a slash /.
Solution 2:
You can try adding this in your page's header:
<base href="/" />