当前位置: 代码迷 >> PHP >> url 重写不成功,不得不打开主页,其他打开都是404报错
  详细解决方案

url 重写不成功,不得不打开主页,其他打开都是404报错

热度:97   发布时间:2016-04-28 18:38:36.0
url 重写不成功,只能打开主页,其他打开都是404报错
url 重写不成功,只能打开主页,其他打开都是404报错..
用的是godaddy的豪华型linux主机。客服说是支持url重写的,网站用的douphp1.1,后台已经开启了url重写,上传了douphp提供的.htaccess到主机根目录。只能打开主页,产品链接都打不开直接404报错。。。附上.htaccess代码,麻烦各位大师指点。有人说把#RewriteBase /前面的#去掉。我试了,不行,有人说要去http.conf配置一下,但是ftp里面根本就没这个文件夹呢。



<FilesMatch "\.(bak|inc|lib|sh|tpl|lbi|dwt)$">
    order deny,allow
    deny from all
</FilesMatch>

RewriteEngine On

#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)

# main
RewriteRule ^index\.html$    index\.php [L]
RewriteRule ^sitemap\.xml$    sitemap\.php [L]
RewriteRule ^(404|301)\.html$    $1\.html [L]

# news
RewriteRule ^news(/o)*([0-9]*)$       article_category\.php\?page=$2   [QSA,L]
RewriteRule ^news(/*)([a-z0-9-]*)(/*o*)([0-9]*)$       article_category\.php\?unique_id=$2&page=$4   [QSA,L]

RewriteRule ^news/([0-9]+)\.html$       article\.php\?id=$1&rewrite=1   [QSA,L]
RewriteRule ^news/([a-z0-9-]+)/([0-9]+)\.html$       article\.php\?id=$2&unique_id=$1   [QSA,L]

# product
RewriteRule ^product(/o)*([0-9]*)$       product_category\.php\?page=$2   [QSA,L]
RewriteRule ^product(/*)([a-z0-9-]*)(/*o*)([0-9]*)$       product_category\.php\?unique_id=$2&page=$4   [QSA,L]

RewriteRule ^product/([0-9]+)\.html$       product\.php\?id=$1&rewrite=1   [QSA,L]
RewriteRule ^product/([a-z0-9-]+)/([0-9]+)\.html$       product\.php\?id=$2&unique_id=$1   [QSA,L]

# onepage
RewriteRule ^([a-z0-9-]+)\.html$       page\.php\?unique_id=$1   [QSA,L]
RewriteRule ^guestbook(/)*([a-z]*)(/*o*)([0-9]*)$       guestbook\.php\?rec=$2&page=$4   [QSA,L]
------解决方案--------------------
你就测试一个最简单的。 
RewriteEngine On

RewriteRule ^1.html$  1.php

建立一个1.php文件
访问1.html看看有没有用。 
------解决方案--------------------
你的重写能生效吗?
应该在
<IfModule mod_rewrite.c>
</IfModule>
中吧?
  相关解决方案