2014-02-19 113 views
0

回來(你會很高興知道我慢慢地進步與你的所有幫助!)到達另一個障礙,這次它與.htaccess ....htaccess modrewrite無法正常工作?

我試圖讓它,讓你可以像這樣訪問......此刻site.co.uk/'username」我已經改變了代碼在我的個人資料頁,看起來像這樣的用戶配置文件...

<?php 
include 'core/init.php'; 

if (isset($_GET['username']) === true && empty($_GET['username']) === false) { 
$username = $_GET['username']; 

echo $username; 
} else { 
header('Location: index.php'); 
exit(); 
} 

?> 

我嘗試添加以下代碼到我的.htaccess文件以使其工作:

//RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !=f 
RewriteCond %{REQUEST_FILENAME} !=d 
RewriteRule ^(.*)$ /userprofile.php?username=$1 

問題是當我嘗試訪問我的網站時,它將我發送到虛擬主機提供程序(000webhost.com)的錯誤頁面。無論我嘗試過什麼,我都無法讓它工作?任何小小的編輯都會讓整個網站停下來?這裏是原來的.htaccess代碼看起來多麼已經上傳你上傳的網站之前,在服務器上(正常工作與此):

<IfModule mod_dir.c> 
DirectoryIndex index.php index.html index.htm user_signup.php user_default_page.php index.html index.shtml index.php 
</IfModule> 

<IfModule mod_deflate.c> 
SetOutputFilter DEFLATE 
</ifmodule> 
<IfModule mod_headers.c> 
<FilesMatch "\.(css|js|jpg|jpeg|gif|png|bmp)$"> 
    Header set Cache-Control "max-age=604800, private, must-revalidate" 
</FilesMatch> 
Header set Vary "Accept-Encoding" 
</ifmodule> 


IndexIgnore * 
<FilesMatch .htaccess> 
Order allow,deny 
Deny from all 
Satisfy All 
</FilesMatch> 

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{QUERY_STRING} ^thankyou-page=([0-9]*)$ 
RewriteRule ^(.*)$ affilates_redirect.php [L] 
</IfModule> 

ErrorDocument 404 /404.php 

會很感激的任何幫助或建議!感謝大師!

+1

變化'= D'到'-d'和'= F'爲'-f',看看是否可行。 – naththedeveloper

+0

我不能相信它就是這麼簡單......非常感謝! – AidanPT

+1

我已經將它添加爲答案,如果您滿意,請接受它,您的問題已解決。 – naththedeveloper

回答

3

這些都不是有效的規則

RewriteCond %{REQUEST_FILENAME} !=f 
RewriteCond %{REQUEST_FILENAME} !=d 

在這種情況下fd是標誌,並應以破折號( - )開頭不是一個等號(=)。

嘗試其更改爲:!!!!

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d