Why is this config code not working in .htaccess?
<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 .htaccess doesn't work.
So what do I need to change to make it work?
G'day,
As mentioned above, the context of the VirtualHost directive explicitly excludes its use in .htaccess files:
From the Apache 2.2 manual:
server config ... means that the directive can be used in server configuration files (for example, httpd.conf), but not inside any or containers. It is not allowed in .htaccess files at all.
NTN
amuses,
a source to share
You cannot use a directive RewriteLog
in .htaccess file
. See Documentation mod_rewrite
. You should also look into the error log when you encounter such problems.
a source to share
The ServerName directive must contain the server name, not the URL. Setting it to www.example.com:80 is valid, but www.example.com/~example is not. See Apache mod_core documentation.
In addition, even if the entry has been commented out, you cannot use the RewriteLog directive in the .htaccess file. See Apache mod_rewrite documentation.
a source to share