Linux 将.htaccess移动到apache 000-default.conf
我正在尝试将.htaccess的内容移动到apache 这是我的.httaccess,运行良好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
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。你需要为虚拟主机明确定义另一个规则。