簡體   English   中英

Ubuntu 14.04LTS Apache2漂亮的URL不起作用

[英]ubuntu 14.04LTS apache2 pretty url's not working

我一直在頭上撞牆,但沒有成功。 我進行了無數次搜索,並嘗試實施所有建議,但仍然不滿意。 我真的很感謝關於為什么我的設置無法正常工作的任何建議。

我們剛剛在具有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

如果有人對如何進行這項工作有任何建議,我將不勝感激。

謝謝。

您的規則缺少目標網址,請將其用作:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)/?$ $1.php [L]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM