My previous folder tree was (with portable xampp): (for example working on D: drive root)
/xampp/htdocs/application
/xampp/htdocs/system
/xampp/htdocs/themes
/xampp/htdocs/index.php etc..
Now I am trying to shift into a structure which I can work with multiple projects so new tree:
/xampp/htdocs
/web_projects/project-name/codeigniter/application
/web_projects/project-name/codeigniter/system
/web_projects/project-name/htdocs/themes
/web_projects/project-name/htdocs/index.php
My htaccess file in htdocs:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
# if Serves works on Linux OS
RewriteRule ^(.*)$ index.php/$1
# if Server works on Windows OS
# RewriteRule ^(.*)$ index.php?/$1
RewriteCond %{REQUEST_FILENAME} !-f
# if Serves works on Linux OS
RewriteRule ^(application|modules|plugins|system|themes|library|files) index.php/$1 [L]
# if Server works on Windows OS
# RewriteRule ^(application|modules|plugins|system|themes|library|files) index.php?/$1 [L]
And httpd-vhosts.conf:
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "/xampp/htdocs"
ServerName localhost
<Directory "/xampp/htdocs">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "/web_projects"
ServerName welcome.localhost
<Directory "/web_projects">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "/web_projects/test/htdocs"
ServerName test.localhost
<Directory "/web_projects/test/htdocs">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Finally etc/host:
127.0.0.1 localhost
127.0.0.1 welcome.localhost
127.0.0.1 test.localhost
127.0.0.1 vstart # Alias for test
All virtual hosts are working, i.e. http://vstart:8080/ is working but codeigniter not operates without index.php in address line, so routes are not working in accordance.
My config/config.php file is:
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['index_page'] = '';
This set was working smoothly in my previous folder tree now is not working. I digged internet to find a solution with failure.
Any outer eyes to catch where I am doing wrong?
Found the solution:
All I need to do is add "AllowOverride All" to respected vhost.
Hope helps someone in the future.
New projects should be place inside the folder of "htdocs"
example:
xampp/htdocs/new_project1/index.htm
xampp/htdocs/new_project1/css
xampp/htdocs/new_project1/images
xampp/htdocs/new_project2/index.htm
xampp/htdocs/new_project2/css
xampp/htdocs/new_project2/images
Related
So I have my symfony 4 app and I have to deploy it on a private server.
My private server (on debian) has already a website in var/www/html/ accessible by 'url.com' My etc/hosts file look like this:
127.0.0.1 localhost
xxx.xx.xx.xx url.com url
I would like my symfony app to be accessible whether by 'app.url.com' or url.com/app.
I tried setting up a vhost and adding my new url to the hosts file by adding a line like this one : xxx.xx.xx.xx app.url.com.
I also tried different VHost conf file but none worked, so I must miss something.
EDIT:
<VirtualHost *:80>
ServerName app.fr
ServerAlias www.app.fr
DocumentRoot "/var/www/html/app/public"
ErrorLog ${APACHE_LOG_DIR}/app-error.log
CustomLog ${APACHE_LOG_DIR}/app-access.log common
<Directory "/var/www/html/app/public">
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =app.fr
RewriteRule ^ http://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
Running LAMP on UBUNTU 14LTS on virtualbox from win7 I found some hiccups.
I'm having trouble displaying my code igniter project in my machine. I have a followed some guides including this one:
tut 1 and tut 2
I can make the current configuration show a single HTML page, called example.com but it cannot show a complete code igniter project, I get this error when running it through the localhost:
NOT FOUND The requested URL /alpa_blog/en was not found on this server.
The project I'm working on is very big so bitnami is a bitslow so I'm planning to change to LAMP that is why I wanted to try and see a little blog on my localhost.
I have not used the LAMP on apache 2.4+ so I'm a little confuse about how to edit some files on vhost and tie them to the config.php inside code igniter.
I've tried a lot of different combination things but no success yet. Now I have my files #:
/etc/apache2/sites-available/alpa_blog.com.conf
/etc/apache2/sites-enabled/alpa_blog.com.conf
Looking like:
<VirtualHost *:80>
ServerName alpa_blog.com
ServerAlias www.alpa_blog.com
DocumentRoot /var/www/html/alpa_blog.com/application
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And # /etc/apache2/sites-available/000-default.conf
looks like:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
Plus my file alpa_blog.com/config/config.php code igniter's folder looks like:
$config['base_url'] = 'alpa_blog.com';
My etc/hosts folder looks like:
127.0.0.1 localhost
127.0.1.1 alpalamp-VirtualBox
127.0.1.1 example.com localhost
127.0.1.1 alpa_blog.com localhost
My var/www/html folder looks like:
alpa_blog.com ci example.com index.html phpinfo.php
Any pointers are much appreciated. Sorry for the your supposed to know that question, but it's driving me nuts.
EDIT:
I've tried several configurations on the .htaccess file.
This is my last version of the .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
And config.php is like:
$config['index_page'] = '';
So after a while I found the answer, I thought to post it here just in case.
Going in the log file located at var/log/apache2/error.log I found this message:
[core:alert] [...] /var/www/html/APP-NAME/www/.htaccess: RewriteRule: bad flag delimiters, turns out that a regex expression was not properly written.
I Ended up by rewriting the rule on the .htaccessfile like this:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|uploads|robots\.txt)
RewriteRule ^(.*)$ /index.php/ [L]
Which solved the issue.
This post also helped out
I'm attempting to figure out why it is that my .htaccess file isn't working - I'm assuming that I am somehow configuring my 000-default.conf incorrectly.
000-default.conf
<VirtualHost *:80>
ServerName ****.********.me
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|css|img|js|libs|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
/html is a symlink to /www in my CodeIgniter project. I have removed 'index.php' from $config['index_page'], and the front page of the site loads without any issue. It is when I attempt to access any other page on the site that the issue arises (they will not load unless I add index.php to the beginning of each). I also ran sudo a2enmod rewrite, to no avail. I have also restarted the apache2 service during all of my attempts at fixing the issue. Any ideas?
If you just wanna remove index.php, then here is the steps to follow :
1- set $config['uri_protocol'] = 'REQUEST_URI';
$config['index_page'] = '';
2- .htaccess file :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
I read about Zend_Controller_Router_Route_Hostname, but i havent idea how.
i try to use it, zend documentation. But when i try to open someoneusername.localhost/ my browser dont found nothing.( Oops! Google Chrome could not find ... ).
i verified my .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
and vhost config
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName localhost
DocumentRoot "/var/www/zendtest/public"
<Directory "/var/www/zendtest/public">
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error-localhost.log
CustomLog ${APACHE_LOG_DIR}/access-localhost.log combined
</VirtualHost>
hosts file
127.0.0.1 localhost
please someone help me.
Assuming everything else has been configured correctly, you'll want to change your VirtualHost Directive:
ServerName localhost
to
ServerName localhost
ServerAlias *.localhost
and then restart apache.
I'm afraid you're out of luck with the hosts file (wildcards unsupported)
See the link for alternatives.
This has been doing my head in. Hope you guys can help. I can't find out where the error lies.
httpd-vhosts.conf
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot /opt/lampp/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot /home/tilman/Sites/mysite/www
ServerName mysite.lo
</VirtualHost>
/etc/hosts
127.0.0.1 localhost
127.0.0.1 mysite.lo
config.php
$config['base_url'] = "http://mysite.lo";
$config['index_page'] = "";
www/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
Now http://mysite.lo shows me the default controller. http://mysite.lo/index.php as well. So does http://mysite.lo/index.php/welcome.
But http://mysite.lo/welcome doesn't.
http://localhost/mysite/www/welcome works as expected.
edit:
I want to move system and application out of the web root.
So my file structure looks like this:
application/
system/
www/
'- index.php
In index.php I changed the paths to system and application folder, of course.
Sounds like you're having rewritemod/htaccess issues rather than VirtualHost issues. Have you made sure that you've got a block such as
<VirtualHost *:80>
ServerName mysite.lo
<Directory /home/tilman/Sites/mysite>
AllowOverride All
</Directory>
</VirtualHost>
somewhere within your config files? The fact that /index.php and /index.php/welcome work, tell me that it's the rewrite mod that's not functioning...
In your virtual host, do you not need this?
<VirtualHost 127.0.0.1>
DocumentRoot /home/tilman/Sites/mysite
ServerName mysite.lo
</VirtualHost>
I'm not sure you needed the www portion.