【问题标题】:.htaccess error after change server更改服务器后.htaccess 错误
【发布时间】:2013-12-11 17:09:57
【问题描述】:

我已经更改了我的主机并在我们使用 .htaccess 文件和这样的代码的一个网站上遇到了 404 错误,现在发生了什么子猫页面显示 404 错误http://www.natural-stones-india.com/sandstone/Golden%20Brown%20Black.html

.htaccess 代码是这样的-----------谁能帮忙?

Options +FollowSymLinks
RewriteEngine on
RewriteRule  ^sandstone/(.*).html$  product.php?sandstone=$1
RewriteRule  ^slate/(.*).html$  product.php?slate=$1
RewriteRule  ^marble/(.*).html$ product.php?marble=$1
RewriteRule  ^granite/(.*).html$    product.php?granite=$1
RewriteRule  ^artifacts/(.*).html$  product.php?artifacts=$1

RewriteRule  ^page/(.*)/sandstone/(.*).html$    product.php?page=$1&sandstone=$2
RewriteRule  ^page/(.*)/granite/(.*).html$  product.php?page=$1&granite=$2
RewriteRule  ^page/(.*)/marble/(.*).html$   product.php?page=$1&marble=$2
RewriteRule  ^page/(.*)/artifacts/(.*).html$    product.php?page=$1&artifacts=$2
RewriteRule  ^page/(.*)/slate/(.*).html$    product.php?page=$1&slate=$2

RewriteRule ^(.*)\.html$ $1.php [nc]

RewriteRule  ^action/(.*)/id/(.*)/cat/(.*)/sub_cat/(.*)shoppingcart.html$   shoppingcart.php?action=$1&id=$2&cat=$3&sub_cat=$4
RewriteCond %{HTTP_HOST} ^natural-stones-india.com
RewriteRule ^(.*)$ http://www.natural-stones-india.com/$1 [R=301,L]

<Files .htaccess>
order allow,deny
deny from all
</Files>

ErrorDocument 404 /missing.html

【问题讨论】:

  • 可以在浏览器中直接进入product.php?sandstone=$1吗? (当然是传递$1 的相关值。)

标签: php .htaccess mod-rewrite


【解决方案1】:

好吧,我们来分析一些事实

结论:你的相对路径有问题

可能的解决方案:

RewriteEngine On
RewriteBase /
...

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteBase

或者将重写目标设置为绝对

例如

RewriteRule  ^sandstone/(.*).html$  /product.php?sandstone=$1

【讨论】:

    【解决方案2】:

    尝试更改您对 .htaccess 文件的访问权限 您应该可以通过 FTP 更改这些。

    你的网站看起来不错,因为我正在工作:http://www.natural-stones-india.com/product.php?sandstone=Golden%20Brown%20Black

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-05
      • 2021-10-19
      • 1970-01-01
      • 2013-01-22
      • 2011-10-03
      • 1970-01-01
      • 2015-09-06
      • 2019-02-12
      相关资源
      最近更新 更多