【问题标题】:My htaccess not working in my website but working in testing site我的 htaccess 不在我的网站上工作,但在测试网站上工作
【发布时间】:2015-02-12 09:45:31
【问题描述】:

最后,我设法编写了 htaccess 代码并在http://htaccess.madewithlove.be/ 中进行了测试,发现它是正确的。

在这个http://htaccess.madewithlove.be/ 中重写 URL 的方式是有效的

但是当我在我的网站中使用相同的 htaccess 代码时不起作用。

新网址http://192.168.1.190/qjyii2/yii2dev3/frontend/web/login.php 实际网址http://192.168.1.190/qjyii2/yii2dev3/frontend/web/index.php?r=site/login

Ht访问代码

RewriteEngine On
RewriteRule ^qjyii2/yii2dev3/frontend/web/([^/]*)\.php$ /qjyii2/yii2dev3/frontend/web/index.php?r=site/$1 [L]

我的 mod_rewrite 在服务器上运行良好。我确实把这个 htaccess 放在 /www/qjyii2/yii2dev3/ 下,但它不起作用。非常感谢任何帮助。

【问题讨论】:

    标签: .htaccess mod-rewrite


    【解决方案1】:

    如果您将其放在/www/qjyii2/yii2dev3/.htaccess 中,请使用以下代码:

    RewriteEngine On
    RewriteBase /www/qjyii2/yii2dev3/
    
    RewriteRule ^(frontend/web)/([^/]*)\.php$ $1/index.php?r=site/$2 [L,NC,QSA]
    

    .htaccess 是每个目录指令,Apache 从 RewriteRule URI 模式中剥离 当前目录路径

    【讨论】:

      猜你喜欢
      • 2022-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多