2013-05-07 53 views
1

所有頁面都通過索引頁面進行解析,但是如果通過索引頁面解析頁面,則PHP代碼不會被解析。並在頁面源代碼中顯示所有的php代碼。我使用.htaccess文件,代碼如下:重定向頁面在php中無法正常工作?

# Use PHP5.4 as default 
AddHandler application/x-httpd-php54 .php 
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^domain\.org [NC] 
RewriteRule ^(.*)$ http://www.domain.org/$1 [R=301,NC] 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^(.*)$ /index.php/$1 [R,L] 
Order allow,deny 
Allow from all 
<Files 403.shtml> 
order allow,deny 
allow from all 
</Files> 

從索引頁中的函數獲取所有文件內容。功能是:

public function getPageContent() 
{ 
    $html = implode('', file($this->_ROOT.$this->getPage())); 
    echo $html; 
} 
+0

所以你不想重定向PHP文件? – 2013-05-07 07:01:50

+0

遐我想重定向php文件,但重定向文件中的php coeds未被解析。例如,如果home.php頁面被重定向到index.php頁面,但home.php頁面中的代碼未被解析。 – Banshi 2013-05-07 07:04:07

+0

你在做什麼index.php?你包括(「」)'home.php? – 2013-05-07 07:06:00

回答

1

發生了什麼事情,你只是要求文件的內容。

file()讓你知道該文件裏面的內容,它以純文本形式返回。如果您需要在您的index.php請求的頁面,例如:

請求:home.php -> index.php?p=home.php

.htaccess 
RewriteRule ^(.*)$ /index.php?p=$1 [R,L] 


index.php 
<?php 
    /* Do some checks to secure the input. */ 
    include($_GET['p']); 
?>