收录日期:2019/10/22 14:29:50 时间:2009-05-25 11:22:56 标签:apache,.htaccess,mod-rewrite
<VirtualHost *:80>
   DocumentRoot /lf/main/com 
   ServerName 74.220.215.241/~laborfa2 
   ServerAlias 74.220.215.241/~laborfa2 
   RewriteEngine on 
   #RewriteLogLevel 2 
   #RewriteLog logs/rewrite.log 
   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php -f 
   RewriteRule ^/(.*)(/?)$ /$1.php [L] 
    RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})(/?)$ /profile.php?fairid=$1$2 [L] 
    RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})/([a-z]*)(/?)$ /$3.php?fairid=$1$2 [L]     

 </VirtualHost>

It works fine on linux(htt.vhost) but when i paste it in .htaccess does not works.

So what do i need to change to make it work?

G'day,

As mentioned above, the context for the VirtualHost directive explicitly excludes its use in .htaccess files:

From the Apache 2.2 manual:

server config ... means that the directive may be used in the server configuration files (e.g., httpd.conf), but not within any or containers. It is not allowed in .htaccess files at all.

HTH

cheers,

You cannot setup a vitual host inside a virtual host.

The <VirtualHost> block that you are using can only be configured inside the httpd.conf file (main server config) and will not work inside .htaccess.

You can try moving the VirtualHost inside httpd.conf and just leving RewriteCond and RewriteRule inside the .htaccess file

The ServerName directive should contain a server name and not a URL. Setting it to a value of www.example.com:80 is valid, but www.example.com/~example is not. See the Apache mod_core documentation.

Other than that, even though the entry has been commented out, you can't use the RewriteLog directive in an .htaccess file. See the Apache mod_rewrite documentation.

You cannot use the RewriteLog directive in a .htaccess file. See the mod_rewrite documentation. You should also take a look in the error log when you run into such problems.