2016-01-20 45 views
0

我想在服務器上使用另一個文件,而不是讓列表文件zindex.php該文件必須功能,如果它實際上存在於上述位置。我以爲我可以用.htaccess做到這一點,但是在淘網之後,我沒有任何資源來做到這一點。這甚至有可能嗎?使用文件代替丟失的文件與.htaccess(而不是重定向)

RewriteEngine On 

RewriteCond $1 !^files 
RewriteCond %{REQUEST_URI} custom_link_ 
RewriteRule .* zindex.php 
+0

如果我理解正確的話,你要當www.example.com/zindex.php被訪問重定向到另一個文件,但在瀏覽器中,這個url應該顯示,對嗎? – Xavjer

回答

1

這將執行zindex.php代替的index.php文件夾你把你的.htaccess

RewriteEngine On 

RewriteRule ^index.php$ zindex.php 

# /index.php    will execute /zindex.php 
# /index.php?query=string will execute /zindex.php //$_GET['query'] === 'string' 
#/      will execute /zindex.php 
# /folder/index.php  will execute /folder/index.php 
+0

這工作完美&將幫助我消除噸相同的文件。但是,我的所有主文件都在根目錄中。 – user1483887