<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 ^/(.*)(/?)$ /
<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.
它在linux(htt.vhost)上工作正常但是当我将它粘贴在.htaccess中时不起作用。
So what do i need to change to make it work?
那么我需要改变什么来使它工作?
5 个解决方案
#1
G'day,
As mentioned above, the context for the VirtualHost directive explicitly excludes its use in .htaccess files:
如上所述,VirtualHost指令的上下文明确排除了在.htaccess文件中的使用:
From the Apache 2.2 manual:
从Apache 2.2手册:
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.
server config ...表示该指令可以在服务器配置文件(例如httpd.conf)中使用,但不能在任何容器或容器中使用。根本不允许在.htaccess文件中使用它。
HTH
cheers,
#2
You cannot setup a vitual host inside a virtual host.
您无法在虚拟主机内设置虚拟主机。
#3
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.
您正在使用的
块只能在httpd.conf文件(主服务器配置)中配置,并且不能在.htaccess内部工作。
You can try moving the VirtualHost inside httpd.conf and just leving RewriteCond and RewriteRule inside the .htaccess file
您可以尝试在httpd.conf中移动VirtualHost,只需在.htaccess文件中添加RewriteCond和RewriteRule
#4
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.
ServerName指令应包含服务器名称而不是URL。将其设置为值www.example.com:80是有效的,但www.example.com/~example不是。请参阅Apache mod_core文档。
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.
除此之外,即使条目已被注释掉,也不能在.htaccess文件中使用RewriteLog指令。请参阅Apache mod_rewrite文档。
#5
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.
您不能在.htaccess文件中使用RewriteLog指令。请参阅mod_rewrite文档。遇到此类问题时,您还应该查看错误日志。
.php [L]
RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})(/?)$ /profile.php?fairid=
<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.
它在linux(htt.vhost)上工作正常但是当我将它粘贴在.htaccess中时不起作用。
So what do i need to change to make it work?
那么我需要改变什么来使它工作?
5 个解决方案
#1
G'day,
As mentioned above, the context for the VirtualHost directive explicitly excludes its use in .htaccess files:
如上所述,VirtualHost指令的上下文明确排除了在.htaccess文件中的使用:
From the Apache 2.2 manual:
从Apache 2.2手册:
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.
server config ...表示该指令可以在服务器配置文件(例如httpd.conf)中使用,但不能在任何容器或容器中使用。根本不允许在.htaccess文件中使用它。
HTH
cheers,
#2
You cannot setup a vitual host inside a virtual host.
您无法在虚拟主机内设置虚拟主机。
#3
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.
您正在使用的
块只能在httpd.conf文件(主服务器配置)中配置,并且不能在.htaccess内部工作。
You can try moving the VirtualHost inside httpd.conf and just leving RewriteCond and RewriteRule inside the .htaccess file
您可以尝试在httpd.conf中移动VirtualHost,只需在.htaccess文件中添加RewriteCond和RewriteRule
#4
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.
ServerName指令应包含服务器名称而不是URL。将其设置为值www.example.com:80是有效的,但www.example.com/~example不是。请参阅Apache mod_core文档。
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.
除此之外,即使条目已被注释掉,也不能在.htaccess文件中使用RewriteLog指令。请参阅Apache mod_rewrite文档。
#5
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.
您不能在.htaccess文件中使用RewriteLog指令。请参阅mod_rewrite文档。遇到此类问题时,您还应该查看错误日志。
[L]
RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})/([a-z]*)(/?)$ /.php?fairid=
<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.
它在linux(htt.vhost)上工作正常但是当我将它粘贴在.htaccess中时不起作用。
So what do i need to change to make it work?
那么我需要改变什么来使它工作?
5 个解决方案
#1
G'day,
As mentioned above, the context for the VirtualHost directive explicitly excludes its use in .htaccess files:
如上所述,VirtualHost指令的上下文明确排除了在.htaccess文件中的使用:
From the Apache 2.2 manual:
从Apache 2.2手册:
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.
server config ...表示该指令可以在服务器配置文件(例如httpd.conf)中使用,但不能在任何容器或容器中使用。根本不允许在.htaccess文件中使用它。
HTH
cheers,
#2
You cannot setup a vitual host inside a virtual host.
您无法在虚拟主机内设置虚拟主机。
#3
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.
您正在使用的
块只能在httpd.conf文件(主服务器配置)中配置,并且不能在.htaccess内部工作。
You can try moving the VirtualHost inside httpd.conf and just leving RewriteCond and RewriteRule inside the .htaccess file
您可以尝试在httpd.conf中移动VirtualHost,只需在.htaccess文件中添加RewriteCond和RewriteRule
#4
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.
ServerName指令应包含服务器名称而不是URL。将其设置为值www.example.com:80是有效的,但www.example.com/~example不是。请参阅Apache mod_core文档。
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.
除此之外,即使条目已被注释掉,也不能在.htaccess文件中使用RewriteLog指令。请参阅Apache mod_rewrite文档。
#5
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.
您不能在.htaccess文件中使用RewriteLog指令。请参阅mod_rewrite文档。遇到此类问题时,您还应该查看错误日志。
[L]
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /lf/main/com