【问题标题】:Wrong 301 htaccess redirection错误的 301 htaccess 重定向
【发布时间】:2012-10-05 14:00:00
【问题描述】:

我的网站上有这段代码,我需要将http://softsolutions.fr 重定向到http://www.softsolutions.fr,但它没有重定向:

<IfModule mod_rewrite.c>    
  Options +FollowSymlinks
  Options +Indexes
  RewriteEngine On

    RewriteCond %{HTTP_HOST} ^softsolutions\.fr
    RewriteRule ^(.*)$ http://www.softsolutions.fr/index.html [R=301,L]     

  RewriteRule    ^$    /index.html    [L]

    # Rewrites "sub.domain.foo/anything" to "sub.domain.foo/anything.php"
    RewriteCond %{REQUEST_FILENAME} !^(.+).php$
    RewriteCond %{REQUEST_FILENAME} !^(.+).pdf$
    RewriteCond %{REQUEST_FILENAME} !^(.+).(html|htm)$
    RewriteRule    ^([a-zA-Z0-9\-\_/]*)$    /$1.php    [L]  

</IfModule>

【问题讨论】:

  • mod_rewrite 是否可用并且 httpd.conf 中的 AllowOverride 设置为允许该站点的 .htaccess 重写?
  • 我是这个问题的新手,我不知道如何确定你问我的问题,你能帮忙,所以我能理解吗?
  • 我要问的基本上是,任何重定向都有效吗?

标签: .htaccess http-redirect


【解决方案1】:

替换那些行:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^softsolutions\.fr
RewriteRule ^(.*)$ http://www.softsolutions.fr/index.html [R=301,L] 

与:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^softsolutions\.fr [NC]
RewriteRule (.*) http://www.%{HTTP_HOST}%{REQUEST_URI}

【讨论】:

  • :( 不行,没用,有什么权限相关的吗?
  • 您应该询问您的主机提供商。
  • 检查这里stackoverflow.com/questions/9021425/… 或删除周围的&lt;IfModule mod_rewrite.c&gt; &lt;/IfModule&gt; 如果您遇到500, Internal Server Error 之类的错误,则它不可用,因此您必须要求您的主机提供商启用它。
  • 你好 Gustonez,我删除了 标签,它没有给出错误,那么它是启用的吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-07
  • 2011-05-01
  • 2011-01-03
  • 2012-03-10
  • 2021-07-22
  • 1970-01-01
相关资源
最近更新 更多