【发布时间】:2015-06-26 23:10:57
【问题描述】:
我已经用头撞墙了一段时间,但没有成功。我进行了多次搜索并尝试实施所有建议,但仍然没有乐趣。对于我的设置为什么不起作用的任何建议,我将不胜感激。
我们刚刚设置了带有 LAMP 环境的 Ubuntu 14.04LTS 的服务器,自从我尝试让它与一个测试站点一起工作以来,它在我的本地 XAMPP 设置上运行得非常好。
这是我的设置:
使用 a2enmode 重写启用 mod_rewrite
更新 /etc/apache2.conf 文件以允许覆盖
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
在 /etc/apache2/sites-available/example.dev.conf 中设置新的虚拟主机
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/example.dev/public_html
ServerName example.dev
ServerAlias www.example.dev
<Directory /var/www/example.dev/public_html>
Options Indexes FollowSymLinks
Require all granted
AllowOverride all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
使用 a2ensite example.dev.conf 启用虚拟主机
将 .htaccess 文件从我的本地环境复制到 /var/www/example.dev/public_html 目录
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php !-f
RewriteRule ^([^\.]+)/$ [NC,L]
</IfModule>
ErrorDocument 404 /404.php
终于用 apache2 reload 重启了 apache
当我尝试转到辅助页面时,我最终还是进入了 404 页面。
我的网站设置是:
example.dev/index.php
subdirectory
file1.php
file2.php
etc.
链接是example.dev/subdirectory/file1.php
如果有人对如何完成这项工作有任何建议,我将不胜感激。
谢谢。
【问题讨论】:
标签: apache .htaccess ubuntu mod-rewrite