簡體   English   中英

在網址重寫中添加真實路徑

[英]Add real path in url rewriting

當我嘗試重新寫入URL並訪問測試頁(test.php)時,在url中添加了真實路徑,因此,我遇到404錯誤。

http://mywebsite.fr/home/web/dev/test/ <-/ home / web /是真實路徑,不能添加到URL。

在我的配置中,我寫的是:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        ServerName *
        ServerAlias *

        DocumentRoot /home/web
        <Directory />
                Options FollowSymLinks
                AllowOverride None
                DirectoryIndex index.php
        </Directory>
        <Directory /home/web/>
                Options Indexes FollowSymLinks
        AllowOverride All
                Order allow,deny
                allow from all
                DirectoryIndex index.php
        </Directory>

在我的htaccess中:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^([^\.]+)$ $1.html [NC,L]

如果要向.php.html等URL添加擴展名,請從.htaccess中刪除顯示的規則,並添加以下行:

Options +MultiViews

Apache's content negotiation module使用Option MultiViews ,該Apache's content negotiation module mod_rewrite 之前運行,並使Apache服務器匹配文件擴展名。 因此/file可以位於URL中,但它將提供/file.php

暫無
暫無

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

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