2016-10-03 85 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