dsmnedc798226 2019-05-28 19:58
浏览 252

无效的命令“location”,可能是由服务器配置中未包含的模块拼写错误或定义的

Currently, I am setting my local environment for a project.

Project runs on production environment with nginx server. But in the local development, using apache server. I've installed LAMP stack on my ubuntu machine. There is already a virtual host file provided and I have setup it. So far I've created xxx.conf file under /etc/apache2/sites-available.

The file includes:

<VirtualHost *:80>        
 ServerName xxx     
 DocumentRoot /home/ubuntuser/Downloads/xxx-master/public

 <Directory "/home/ubuntuser/Downloads/xxx-master/public">            
    Options Indexes FollowSymLinks Includes ExecCGI            
    AllowOverride all            
    Require all granted        
 </Directory>

 ErrorLog ${APACHE_LOG_DIR}/xxx-error.log        
 CustomLog ${APACHE_LOG_DIR}/xxx-access.log combined        
 SetEnv ENVIRONMENT "development"
</VirtualHost>


I also created .htaccess file under /home/ubuntuser/Downloads/xxx-master/public. The content of this file downloaded from production environment.

The content of .htaccess file is:

RewriteEngine On 
RewriteBase / 
location ~ ^/site { rewrite ^/site(.*)$ https://local.xxx.com/$1 redirect;}

So, when I type local.xxx.com in browser, it gives 500 Internal Error.

So, I was defined xxx-error.log in virtual host config file. I've opened it. The content is:

[Tue May 28 22:23:33.231851 2019] [core:alert] [pid 5677] [client 127.0.0.1:56504] /home/ubuntuser/Downloads/xxx-master/public/.htaccess: RewriteBase takes one argument, the base URL of the per-directory context
[Tue May 28 22:23:33.254608 2019] [core:alert] [pid 5678] [client 127.0.0.1:56506] /home/ubuntuser/Downloads/xxx-master/public/.htaccess: RewriteBase takes one argument, the base URL of the per-directory context, referer: http://local.xxx.com/
[Tue May 28 22:33:22.300863 2019] [core:alert] [pid 6326] [client 127.0.0.1:56740] /home/ubuntuser/Downloads/xxx-master/public/.htaccess: Invalid command 'location', perhaps misspelled or defined by a module not included in the server configuration
[Tue May 28 22:33:22.317420 2019] [core:alert] [pid 6327] [client 127.0.0.1:56742] /home/ubuntuser/Downloads/xxx-master/public/.htaccess: Invalid command 'location', perhaps misspelled or defined by a module not included in the server configuration, referer: http://local.xxx.com/

So, I understand there is problem in the .htaccess but i don't know how to solve it.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图