Forums / Install & configuration / virtualhost and rewriterule ok. need to avoid indexphp!!

virtualhost and rewriterule ok. need to avoid indexphp!!

Author Message

Valentina Ferrari

Wednesday 09 March 2005 2:26:51 am

hi all
i've modified my apache's http.conf file in order to have my sites working in virtualhost mode. (working on w2k)
to do so i added the following lines:

<VirtualHost *>
	DocumentRoot c:/programmi/eZpublish/ezpublish
    	ServerAdmin [email protected]
    	# /www/docs/dummy-host.example.com
    	ServerName 192.168.1.202
	<Directory c:/programmi/eZpublish/ezpublish>
		Options FollowSymLinks Indexes ExecCGI
		AllowOverride None
	</Directory>
    	#ErrorLog logs/dummy-host.example.com-error_log
    	#CustomLog logs/dummy-host.example.com-access_log common

	DirectoryIndex index.php

	RewriteEngine On
	#RewriteRule !\.(js|gif|css|jpg|png)$ /index.php
	RewriteRule !(^/design|^/var/.*/storage|^/var/storage|^/var/.*/cache|^/var/cache|^/extension/.*/design|^/kernel/setup/packages|^/packages|^/share/icons).*\.(gif|css|jpg|png|jar|js|ico|pdf|swf)$ /index.php	
</VirtualHost>

when i restarted apache everything worked fine:
i can access my site simply by writing "http://mysite", not "http://mysite/index.php".
I get the problem when i click on the links in my tpl files, because they still call "http://mysite/index.php/content/view/full/500" instead of "http://mysite/content/view/full/500".
Is there a way to avoid the string "index.php" in my urls? i've been searching in the documentation but i didn't see anything clear to me.

tia
Valentina

Ɓukasz Serwatka

Wednesday 09 March 2005 2:39:29 am

Hi Valentina,

More about configuration and Virtual Hosts you can find here
http://ez.no/ez_publish/documentation/installation/virtual_host_setup
http://ez.no/ez_publish/documentation/configuration/security/non_virtualhost

Try to use ezroot() instead of ezurl()

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Jack Rackham

Wednesday 09 March 2005 4:46:51 am

You cud try this. Example for apache2 on Linux - Name-based Virtual Host, EZ publish 3.5.1:

Or you cud try to run some of the ez publish scripts, located in upgrade/common/scripts.

#
#VirtualHost template:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#



NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName www.ez.no:80
    
    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    DocumentRoot /home/.../ezpublish-3.5.1/

    # if not specified, the global error log is used
    ErrorLog /var/log/apache2/ez.no-error_log
    CustomLog /var/log/apache2/ez.no-access_log combined

    # don't loose time with IP address lookups
    HostnameLookups Off

    # needed for named virtual hosts
    UseCanonicalName Off

    # configures the footer on server-generated documents
    ServerSignature On


    # Optionally, include *.conf files from /etc/apache2/conf.d/
    #
    # For example, to allow execution of PHP scripts:
    #
    Include /etc/apache2/conf.d/mod_php4.conf
    #
    # or, to include all configuration snippets added by packages:
    Include /etc/apache2/conf.d/*.conf


    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the realname directory are treated as applications and
    # run by the server when requested rather than as documents sent to the client.
    # The same rules about trailing "/" apply to ScriptAlias directives as to
    # Alias.
    #
    ScriptAlias /cgi-bin/ "/home/.../ezpublish-3.5.1/cgi-bin/"

    # "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have one, and where ScriptAlias points to.
    #
    <Directory "/home/..../ezpublish-3.5.1/cgi-bin/">
	AllowOverride None
	Options +ExecCGI -Includes
	Order allow,deny
	Allow from all
    </Directory>

    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "/home/..../ezpublish-3.5.1/">
    
	#
	# Possible values for the Options directive are "None", "All",
	# or any combination of:
	#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
	#
	# Note that "MultiViews" must be named *explicitly* --- "Options All"
	# doesn't give it to you.
	#
	# The Options directive is both complicated and important.  Please see
	# http://httpd.apache.org/docs-2.0/mod/core.html#options
	# for more information.
	#
	Options FollowSymLinks
    
	#
	# AllowOverride controls what directives may be placed in .htaccess files.
	# It can be "All", "None", or any combination of the keywords:
	#   Options FileInfo AuthConfig Limit
	#
	AllowOverride All 
    
	#
	# Controls who can get stuff from this server.
	#
	Order allow,deny
	Allow from all
    
    </Directory>

RewriteEngine On
RewriteRule !(^/design|^/var/.*/storage|^/var/storage|^/var/.*/cache|^/var/cache|^/extension/.*/design|^/kernel/setup/packages|^/packages|^/share/icons).*\.(gif|css|jpg|png|jar|js|ico|pdf|swf)$ /index.php

</VirtualHost>

http://httpd.apache.org/docs-2.0/vhosts/name-based.html

Valentina Ferrari

Wednesday 09 March 2005 6:17:23 am

i'm sorry but i didn't be able to understand what you wrote...
i understood i'd have to use the rewriterule directive to redirect all the calls to mysite/index.php/content/... to mysite/content/...
anyone could tell me how? can i have the directive syntax?
i cannot use ezroot() instead of ezurl(): have too many sites to modify, and also i'll have to change the admin templates! i hope it will be another way...

best regards
Valentina

Jack Rackham

Wednesday 09 March 2005 8:56:54 am

For nice urls(no index.php) run this script
./update/common/scripts/updateniceurls.php

Neil Kanth

Friday 22 April 2005 2:29:10 pm

The 'phpMyAdmin' works but I can't get the others to work.

This is the <Virtualhost> section of the httpd file:
NameVirtualHost *:80

<VirtualHost *:80>
<Directory "/home/webadmin/mahaiconysportsclub.com/html">
Options FollowSymLinks
AllowOverride None
</Directory>

<IfModule mod_php4.c>
# If you are using Apache 2, you have to use <IfModule sapi_apache2.c>
# instead of <IfModule mod_php4.c>.

# some parts/addons might only run with safe mode off
php_admin_flag safe_mode Off
# security just in case
php_admin_value register_globals 0
# performance
php_value magic_quotes_gpc 0
# performance
php_value magic_quotes_runtime 0
#http://www.php.net/manual/en/ini.sect.language-options.php#ini.allow-call-time-pass-reference
php_value allow_call_time_pass_reference 0
</IfModule>

# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.

ScriptAlias "/cgi-bin/" "/home/webadmin/mahaiconysportsclub.com/cgi-bin/"

# "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have one, and where ScriptAlias points to.

ScriptAlias /cgi-bin/awstats /var/www/cgi-bin/awstats
Alias /awstats /var/www/html/awstats
ScriptAlias /mail /var/www/cgi-bin/openwebmail/openwebmail.pl
ScriptAlias /cgi-bin/openwebmail /var/www/cgi-bin/openwebmail
Alias /openwebmail /var/www/html/openwebmail
ScriptAlias /cgi-bin/FormMail.pl /var/www/cgi-bin/FormMail.pl
Alias /phpMyAdmin /home/webadmin/mahaiconysportsclub.com/html/phpMyAdmin

# have fallback if mod_rewrite is not existent
DirectoryIndex index.php

<IfModule mod_rewrite.c>
RewriteEngine On
# Use one of the rewrite rules below:
# eZ publish <= 3.3.x:
# RewriteRule !(^/design|^/var/.*/storage|^/var/storage|^/var/.*/cache|^/var/cache|^/extension/.*/design|^/kernel/setup/packages).*\.(gif|css|jpg|png|jar|js|ico|pdf|swf)$ /index.php
# eZ publish >= 3.4.x :
RewriteCond %{REQUEST_URI} !^/awstats.*
RewriteCond %{REQUEST_URI} !^/openwebmail.*
RewriteCond %{REQUEST_URI} !^/FormMail.pl.*
RewriteCond %{REQUEST_URI} !^/phpMyAdmin.*
RewriteRule !(^/design|^/var/.*/storage|^/var/storage|^/var/.*/cache|^/var/cache|^/extension/.*/design|^/kernel/setup/packages|^/packages|^/share/icons).*\.(gif|css|jpg|png|jar|js|ico|pdf|swf)$ /index.php
</IfModule>

DocumentRoot "/home/webadmin/mahaiconysportsclub.com/html"
ServerName "www.mahaiconysportsclub.com"
ServerAlias "mahaiconysportsclub.com"
ServerAdmin "[email protected]"
</VirtualHost>

These lines were already in the httpd file:
<i> ScriptAlias /cgi-bin/awstats /var/www/cgi-bin/awstats
Alias /awstats /var/www/html/awstats
ScriptAlias /mail /var/www/cgi-bin/openwebmail/openwebmail.pl
ScriptAlias /cgi-bin/openwebmail /var/www/cgi-bin/openwebmail
Alias /openwebmail /var/www/html/openwebmail
ScriptAlias /cgi-bin/FormMail.pl /var/www/cgi-bin/FormMail.pl</i>

What changes do I need to make?

Jack Rackham

Saturday 23 April 2005 2:47:47 pm

I don't think you shod place the ServerName and the rest of those settings on the bottom.

See
Apache 2 vhost
http://httpd.apache.org/docs-2.0/vhosts/

Apache 1.3 vhost
http://httpd.apache.org/docs/vhosts/index.html

kracker (the)

Monday 25 April 2005 2:01:50 am

I firmly disagree with the previous post entirely.

The position of the referenced information is secondary and for all tense and purposes just not an issue...

//kracker

i could be wrong, it could be a horrible mistake, resume changeover ...

Member since: 2001.07.13 || http://ezpedia.se7enx.com/