Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.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
Linux 将.htaccess移动到apache 000-default.conf_Linux_Apache_Ubuntu - Fatal编程技术网

Linux 将.htaccess移动到apache 000-default.conf

Linux 将.htaccess移动到apache 000-default.conf,linux,apache,ubuntu,Linux,Apache,Ubuntu,我正在尝试将.htaccess的内容移动到apache 这是我的.httaccess,运行良好 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^contact-me/?$ index.php?page=contact [NC,L] RewriteRule

我正在尝试将.htaccess的内容移动到apache

这是我的.httaccess,运行良好

     RewriteEngine On
     RewriteBase /
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^contact-me/?$ index.php?page=contact [NC,L]
     RewriteRule ^about-me/?$ index.php?page=about [NC,L]
我将.htaccess代码移动到000-default.connf,如下所示:

     <VirtualHost *:80>
     ServerName www.mysite.com

     <Directory /var/www/>

     RewriteEngine On
     RewriteBase /
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^contact-me/?$ index.php?page=contact [NC,L]
     RewriteRule ^about-me/?$ index.php?page=about [NC,L]

     </Directory>
     </VirtualHost>

服务器名www.mysite.com
重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^contact me/?$index.php?page=联系人[NC,L]
重写规则^about me/?$index.php?page=关于[NC,L]
这是行不通的,但如果我用“拒绝所有人”或其他规则,它就行了

     RewriteEngine On
     RewriteBase /
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^contact-me/?$ index.php?page=contact [NC,L]
     RewriteRule ^about-me/?$ index.php?page=about [NC,L]

有什么想法吗?

你在使用apache 2.4吗?是的,我正在使用最新版本。你可能需要添加此
require all-grated
,参考:我在apache2.conf中已经有require all-grated。你需要为虚拟主机明确定义另一个规则。