2016-10-03 82 views
-1

我需要你的幫助我想改變我的URL格式,但我不能這樣做,我不斷收到Object Not Found錯誤。如何更改使用htaccess url格式

真實網址爲:http://localhost/website/page.php?pid=about

我使用htaccess的希望類似這樣的URL http://localhost/website/about.php

我的代碼是:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    #RewriteCond %{HTTP_HOST} !^www\. 
    #RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 

    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}.php !-f 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(([a-zA-z0-9\_\-\+]+))\.html|([a-zA-z0-9\_\-]+)\.php$ page.php?pptype=$2&pppage=$3&id=$4 [QSA,NC,L] 

</IfModule> 
+1

的可能的複製[?htaccess的乾淨的URL什麼是做到這一點的最好辦法(http://stackoverflow.com/questions/12661287/ htaccess-clean-urls-what-the-best-way-do-it) – Dez

回答

0

嘗試像這樣爲您的網址類似於http://localhost/website/about.php

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewrwiteRule ^([\w-]+)/([\w-]+).php$ $1/page.php?pid=$2 [L] 
+0

我再次遇到同樣的問題,找不到對象。 –

0

在您的中使用此功能:

RewriteEngine On 
RewriteRule ^website/([^/]*)\.php$ /website/page.php?pid=$1 [L] 

它會離開你的網址:http://localhost/website/about.php