Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 为什么此配置代码在.htaccess中不起作用? DocumentRoot/lf/main/com 服务器名74.220.215.241/~laborfa2 服务器别名74.220.215.241/~laborfa2 重新启动发动机 #重写日志级别2 #重写日志/rewrite.log RewriteCond%{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php-f 重写规则^/(.*)(/?)$/$1.php[L] 重写规则^/([a-zA-Z]+)([a-zA-Z0-9!]{3,15})(/?)$/profile.php?fairid=$1$2[L] 重写规则^/([a-zA-Z]+)([a-zA-Z0-9!]{3,15})/([a-Z]*)(/?)$/$3.php?fairid=$1$2[L]_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache 为什么此配置代码在.htaccess中不起作用? DocumentRoot/lf/main/com 服务器名74.220.215.241/~laborfa2 服务器别名74.220.215.241/~laborfa2 重新启动发动机 #重写日志级别2 #重写日志/rewrite.log RewriteCond%{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php-f 重写规则^/(.*)(/?)$/$1.php[L] 重写规则^/([a-zA-Z]+)([a-zA-Z0-9!]{3,15})(/?)$/profile.php?fairid=$1$2[L] 重写规则^/([a-zA-Z]+)([a-zA-Z0-9!]{3,15})/([a-Z]*)(/?)$/$3.php?fairid=$1$2[L]

Apache 为什么此配置代码在.htaccess中不起作用? DocumentRoot/lf/main/com 服务器名74.220.215.241/~laborfa2 服务器别名74.220.215.241/~laborfa2 重新启动发动机 #重写日志级别2 #重写日志/rewrite.log RewriteCond%{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php-f 重写规则^/(.*)(/?)$/$1.php[L] 重写规则^/([a-zA-Z]+)([a-zA-Z0-9!]{3,15})(/?)$/profile.php?fairid=$1$2[L] 重写规则^/([a-zA-Z]+)([a-zA-Z0-9!]{3,15})/([a-Z]*)(/?)$/$3.php?fairid=$1$2[L],apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,它在linux(htt.vhost)上运行良好,但当我将其粘贴到中时,htaccess就不起作用了 那么我需要做哪些更改才能使其正常工作呢?您不能在.htaccess文件中使用RewriteLog指令。看。遇到此类问题时,您还应该查看错误日志。您无法在虚拟主机中设置虚拟主机。您使用的块只能在httpd.conf文件(主服务器配置)中配置,并且不能在htaccess中工作 您可以尝试将VirtualHost移动到httpd.conf中,只需在.htaccess文件中设置RewriteCond和Re

它在linux(htt.vhost)上运行良好,但当我将其粘贴到中时,htaccess就不起作用了


那么我需要做哪些更改才能使其正常工作呢?

您不能在
.htaccess文件中使用
RewriteLog
指令。看。遇到此类问题时,您还应该查看错误日志。

您无法在虚拟主机中设置虚拟主机。

您使用的
块只能在httpd.conf文件(主服务器配置)中配置,并且不能在htaccess中工作


您可以尝试将VirtualHost移动到httpd.conf中,只需在.htaccess文件中设置RewriteCond和RewriteRule,ServerName指令应该包含服务器名称而不是URL。将其设置为值www.example.com:80有效,但www.example.com/~example无效。请参阅Apache mod_核心文档

除此之外,即使条目已注释掉,也不能在.htaccess文件中使用RewriteLog指令。请参阅Apache mod_重写文档。

G'day

如上所述,VirtualHost指令的上下文明确排除了其在.htaccess文件中的使用:

从Apache 2.2手册:

服务器配置。。。意味着该指令可以在服务器配置文件(例如httpd.conf)中使用,但不能在任何或容器中使用。在.htaccess文件中根本不允许使用它


干杯,

请正确设置代码格式!将每行缩进4个空格字符,将其格式化为代码块。使用.htaccess运行上述代码时,我将使用什么?因为我正在将我的站点从linux传输到共享服务器。例如,对于“Document_Root”使用什么?使用.htaccess运行上述代码时我将使用什么?因为我正在将我的站点从linux传输到共享服务器。例如,我将使用什么作为“Document\u Root”
<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>