Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 5th December 2011, 11:23
GarGamel55 GarGamel55 is offline
Member
 
Join Date: Jul 2011
Posts: 30
Thanks: 6
Thanked 3 Times in 3 Posts
Default Url rewriting in vhost add a slash /

Hi,

In my .htaccess i've this rule :
Code:
RewriteRule ^(.*)\.html$ /?page=$1 [R,L]
it works very well : website.com/test.html returns website.com/?page=test

But if I put directly in my vhost (since panel websites/options/Directives Apache), i've an error :
Code:
RewriteRule ^(.*)\.html$ /?page=$1 [R,L]
website.com/test.html returns website/?page=/test instead of website.com/?page=test

Why a "/" is added?

Thanks
__________________
French webmaster
Reply With Quote
Sponsored Links
  #2  
Old 5th December 2011, 11:28
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,502
Thanks: 813
Thanked 5,264 Times in 4,128 Posts
Default

The redirect function is made to redirect a domain to a directory and not to a single file. For that reason it adds a / at the end if no / is added.

For the rewrite rule that you posted above, create a file named .htaccess in the web directory and add the rule there.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 5th December 2011, 11:41
GarGamel55 GarGamel55 is offline
Member
 
Join Date: Jul 2011
Posts: 30
Thanks: 6
Thanked 3 Times in 3 Posts
Default

I already have one .htaccess file with a lot of rules in the directory /web.

I want to put all the rules directly into the vhost to ensure that the file is not loaded on every page visited. (I have over 5,000,000 page views per month)

So it is not possible?
__________________
French webmaster
Reply With Quote
  #4  
Old 5th December 2011, 11:53
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,502
Thanks: 813
Thanked 5,264 Times in 4,128 Posts
Default

Quote:
So it is not possible?
Sure, just add them in the apache directives field.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #5  
Old 5th December 2011, 11:55
GarGamel55 GarGamel55 is offline
Member
 
Join Date: Jul 2011
Posts: 30
Thanks: 6
Thanked 3 Times in 3 Posts
Default

This is what I do since the beginning and what I always slash which is added
__________________
French webmaster
Reply With Quote
  #6  
Old 5th December 2011, 11:58
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,502
Thanks: 813
Thanked 5,264 Times in 4,128 Posts
Default

The rewrite rules that you enter in the apache directives field are not altered by ispconfig. You can check that in the vhost file.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #7  
Old 5th December 2011, 13:21
GarGamel55 GarGamel55 is offline
Member
 
Join Date: Jul 2011
Posts: 30
Thanks: 6
Thanked 3 Times in 3 Posts
 
Default

I am looking for several days, but i've no idea

My vhost apache2
Code:
<Directory /var/www/website.com>
    AllowOverride None
    Order Deny,Allow
    Deny from all
</Directory>

<VirtualHost *:82>
      DocumentRoot /var/www/website.com/web

    ServerName website.com
    ServerAlias www.website.com
    ServerAdmin webmaster@website.com

    ErrorLog /var/log/ispconfig/httpd/website.com/error.log


    ErrorDocument 400 /error/400.html
    ErrorDocument 401 /error/401.html
    ErrorDocument 403 /error/403.html
    ErrorDocument 404 /error/404.html
    ErrorDocument 405 /error/405.html
    ErrorDocument 500 /error/500.html
    ErrorDocument 502 /error/502.html
    ErrorDocument 503 /error/503.html

    <IfModule mod_ssl.c>
    </IfModule>
    <Directory /var/www/website.com/web>
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    <Directory /var/www/clients/client0/web2/web>
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    # Clear PHP settings of this website
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler None
    </FilesMatch>
    # php as fast-cgi enabled
        # For config options see: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
    <IfModule mod_fcgid.c>
        IdleTimeout 300
        ProcessLifeTime 3600
        # MaxProcessCount 1000
        DefaultMinClassProcessCount 0
        DefaultMaxClassProcessCount 100
        IPCConnectTimeout 3
        IPCCommTimeout 360
        BusyTimeout 300
    </IfModule> 
	
	<Directory /var/www/clients/client0/web2/web>
        AddHandler fcgid-script .php .php3 .php4 .php5
        FCGIWrapper /var/www/php-fcgi-scripts/web2/.php-fcgi-starter .php
        Options +ExecCGI
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^website.com$ [NC]
    RewriteRule ^(.*)$ http://www.website.com$1 [R=301,L]

    # add support for apache mpm_itk
    <IfModule mpm_itk_module>
      AssignUserId web2 client0
    </IfModule>

    <IfModule mod_dav_fs.c>
          # Do not execute PHP files in webdav directory
      <Directory /var/www/clients/client0/web2/webdav>
            <FilesMatch "\.ph(p3?|tml)$">
          SetHandler None
        </FilesMatch>
      </Directory>
      # DO NOT REMOVE THE COMMENTS!
      # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
      # WEBDAV BEGIN
      # WEBDAV END
    </IfModule>

RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD)\ (/.*)?/index.(htm|html|php|asp)
RewriteRule ^(.*)index.(htm|html|php|asp)$ /$1 [R=301,L]

RewriteRule ^(.*)\.html$ /?page=$1 [R,L]
</VirtualHost>

My nginx vhost (for statics)

Code:
server {
        server_name www.website.com;

        location ~* \.(jpg|jpeg|gif|css|png|js|ico|swf|mp3)$ {
        #replace $host by domain without www.
        root   /var/www/www/website.com/web;
        expires       7d;
        access_log     off;
        }

        location / {
        proxy_pass http://127.0.0.1:82;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        access_log off;
        }
}
__________________
French webmaster
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
rewriting url from one directory to top of another DantePasquale Installation/Configuration 5 10th February 2011 09:52
freebsd 7, samba 3, domain controller alexdimarco Suggest HOWTO 6 5th November 2010 16:54
How to enable URL rewriting bjarne-j Installation/Configuration 2 3rd November 2008 22:47
Add new vhost , how? unkn0wn Server Operation 2 5th December 2006 18:02
webmail url trailing slash hairydog2 Installation/Configuration 4 2nd November 2005 21:39


All times are GMT +2. The time now is 14:43.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.