的.htaccess不工作在我的Ubuntu 14.04发行 [英] .htaccess not working on my Ubuntu 14.04 Distribution

查看:215
本文介绍了的.htaccess不工作在我的Ubuntu 14.04发行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚才已经配置在我的Ubuntu 14.04发行我的LAMP堆栈,并要设置的.htaccess 起来服务于网站。

我也跟着教程的https:// WWW。 digitalocean.com/community/tutorials/how-to-use-the-htaccess-file 并配置了我的域名虚拟主机,但是我仍然无法使用.htaccess文件在我的项目的根,每当我尝试以服务网页,我收到了 404错误

.conf文件文件为我的域名是这样的:

 <虚拟主机*:80>
 的ServerAdmin alexmk92@live.co.uk
 服务器名alexsims.me
 ServerAlias​​ www.alexsims.me
 DocumentRoot的/var/www/alexsims.me <目录/>
    有FollowSymLinks
    设置AllowOverride无
 < /目录> <目录/var/www/alexsims.me>
    选择指数多视图了FollowSymLinks
    设置AllowOverride无
    为了允许,拒绝
    所有允许
 < /目录>
 错误日志$ {} APACHE_LOG_DIR /error.log
 的CustomLog $ {} APACHE_LOG_DIR结合/access.log
 < /虚拟主机>

我试图的AllowOverride无更改为的AllowOverride全部但是,即使启用后引起内部500错误的mod_rewrite

问候,
亚历克斯。

编辑:的.htaccess 内容

  #Force WWW:
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^ alexsims.me [NC]
重写规则^(。*)$ http://www.alexsims.me/$1 [L,R = 301,NC]#---重写PHP文件清理网址
的RewriteCond%{} SCRIPT_FILENAME!-d
重写规则^([A-ZA-Z0-9 - ] +)?$页面= $ 1 [NC,L]
重写规则^([A-ZA-Z0-9 - ] +)/([A-ZA-Z0-9 - ] +)$页= $ 1安培;?ID = $ 16 [NC,L]


解决方案

尝试

 要求所有批准

代替

 令允许,拒绝
所有允许

查看升级文档更多信息:


  

在2.2,访问控制基于客户的主机名,IP地址,以及其他
  客户端请求的特征是使用指令完成
  令,允许,拒绝,最大限度的满足。


  
  

在2.4,例如访问控制以相同的方式与其他做
  授权检查,使用新的模块mod_authz_host。老人
  访问控制成语应该由新的认证取代
  机制,虽然旧配置的兼容性,
  新模块mod_access_compat提供。


I have just configured my LAMP stack on my Ubuntu 14.04 distribution and want to set .htaccess up to serve a website.

I followed the tutorial https://www.digitalocean.com/community/tutorials/how-to-use-the-htaccess-file and configured a virtual host for my domain, however I am still unable to use the .htaccess file in my projects root, whenever I try to serve a page I get a 404 error.

The .conf file for my domain looks like:

 <VirtualHost *:80>
 ServerAdmin alexmk92@live.co.uk
 ServerName alexsims.me
 ServerAlias www.alexsims.me
 DocumentRoot /var/www/alexsims.me

 <Directory />
    Options FollowSymLinks
    AllowOverride None
 </Directory>

 <Directory /var/www/alexsims.me>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
 </Directory>


 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
 </VirtualHost>

I tried to change AllowOverride None to AllowOverride All but that caused an internal 500 error even after enabling mod_rewrite.

Regards, Alex.

EDIT: .htaccess contents

#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^alexsims.me [NC]
RewriteRule ^(.*)$ http://www.alexsims.me/$1 [L,R=301,NC]

#--- Rewrite PHP files clean URL
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)$ ?page=$1 [NC,L]
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)$ ?page=$1&id=$2 [NC,L]

解决方案

Try

Require all granted

in place of

Order allow,deny
allow from all

See the upgrade documentation for more info:

In 2.2, access control based on client hostname, IP address, and other characteristics of client requests was done using the directives Order, Allow, Deny, and Satisfy.

In 2.4, such access control is done in the same way as other authorization checks, using the new module mod_authz_host. The old access control idioms should be replaced by the new authentication mechanisms, although for compatibility with old configurations, the new module mod_access_compat is provided.

这篇关于的.htaccess不工作在我的Ubuntu 14.04发行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆