我一直在打我的头靠在这堵墙一会儿都没有成功。我做了很多搜索,试图实现所有的建议,但仍然没有喜悦。我真的很感激任何建议,为什么我的设置不工作。Ubuntu的14.04LTS的Apache2漂亮的URL不工作
我们刚刚建立服务器与Ubuntu 14.04LTS与LAMP环境,从那以后我一直在试图使其与一个试验场,它工作在我的本地XAMPP安装完全正常工作。
这里是我的设置看起来像:
与a2enmode启用了mod_rewrite重写
更新/etc/apache2.conf文件,以允许在/ etc覆盖
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
设置新的虚拟主机/apache2/sites-available/example.dev.conf
<VirtualHost *:80>
ServerAdmin [email protected]
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>
enable与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重启apache的重装
而当我尝试去辅助页面时,我仍然在404页面上。
我的网站设置为:
example.dev/index.php
subdirectory
file1.php
file2.php
etc.
并且链接example.dev/subdirectory/file1.php
如果任何一个有关于如何使这项工作,我会什么建议感激。
谢谢。
我想你的建议,仍然没有喜悦。我仍然发送到404页面。 – PeterA
它是活跃的,当我把废话放进去时它会产生500错误,并且ErrorDocument工作得很好,因为那是它发送给我的地方。以及当我将.php添加到文件名的末尾时它会起作用。这令我非常困惑。 – PeterA
好吧。什么是.php文件的正确工作网址? – anubhava