【问题标题】:rewrite rule is not working in .htaccess file重写规则在 .htaccess 文件中不起作用
【发布时间】:2012-11-09 10:51:53
【问题描述】:

在我的门户中,我调用了一个 pdf 文件,路径看起来像 http://www.mysite.com/filespath/books/online_bliss_in_five_simple_steps_1339668056/live/online_dating_bliss_in_five_simple_steps_1339668056.php

为了用户接受,我需要减少这个 url。然后我在 .htaccess 文件中添加一个代码。添加此行后,当我调用我的门户时,仅显示一个白页 代码是

RewriteEngine On
RewriteRule    ^book/([A-Za-z0-9-]+_.)/?$  /live/$1.php    [NC,L]

请帮帮我

【问题讨论】:

  • 你能给我们一个你想做的例子吗(URL之前/URL之后)?
  • 在我需要域名之前-www.example.com

标签: php .htaccess url


【解决方案1】:

试试这个:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC]
RewriteRule ^(.*)$ http://www.askapache.com/$1 [R=301,L]

更多参考请点击Here

【讨论】:

    【解决方案2】:

    尝试编写完整路径:

    RewriteEngine On
    RewriteBase /filespath/book/
    RewriteRule ^([A-Za-z0-9-]+_.)/?$ $1/live/$1.php [NC,L]
    

    【讨论】:

      猜你喜欢
      • 2017-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多