【问题标题】:htaccess rewrite not working?htaccess重写不起作用?
【发布时间】:2015-12-22 22:22:42
【问题描述】:

我尝试了很长时间,但不明白这一点。 我的 .htaccess 文件中有以下代码:

RewriteEngine On
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteCond %{REQUEST_URI} !/$
  RewriteRule ^(.*)$  $1\.php

RewriteRule ^product/([0-9])/$ product?id=$1 [L]
RewriteRule ^product - [L] 

最后 2 个 RewriteRule 不起作用。 示例网址:www.samplesite.com/product?id=444100 我想改写成:ww.samplesite.com/product/444100

你能帮帮我吗?

谢谢你!

【问题讨论】:

    标签: .htaccess mod-rewrite rewrite


    【解决方案1】:

    [0-9] 将只匹配一个数字。

    按照不同的顺序排列:

    Options -MultiViews
    RewriteEngine On
    
    RewriteRule ^product/(\d+)/?$ product?id=$1 [L,QSA,NC]
    
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.+?)/?$  $1.php [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-06
      • 2015-02-03
      • 2015-10-28
      • 2014-08-08
      • 2011-07-05
      • 1970-01-01
      相关资源
      最近更新 更多