我的 htaccess 不在我的网站上工作,但在测试站点上工作
My htaccess not working in my website but working in testing site
终于写出了htaccess的代码,在http://htaccess.madewithlove.be/中进行了测试,发现是正确的。
在此 http://htaccess.madewithlove.be/ 中重写 URL 的方式有效
但是当我在我的网站中使用相同的 htaccess 代码时,它不起作用。
新 URL http://192.168.1.190/qjyii2/yii2dev3/frontend/web/login.php
实际 URL http://192.168.1.190/qjyii2/yii2dev3/frontend/web/index.php?r=site/login
Htaccess 代码
RewriteEngine On
RewriteRule ^qjyii2/yii2dev3/frontend/web/([^/]*)\.php$ /qjyii2/yii2dev3/frontend/web/index.php?r=site/ [L]
我的 mod_rewrite 在服务器上运行良好。我确实把这个 htaccess 放在 /www/qjyii2/yii2dev3/ 下,但它不起作用。非常感谢任何帮助。
如果您将其放在 /www/qjyii2/yii2dev3/.htaccess
中,则使用此代码:
RewriteEngine On
RewriteBase /www/qjyii2/yii2dev3/
RewriteRule ^(frontend/web)/([^/]*)\.php$ /index.php?r=site/ [L,NC,QSA]
.htaccess
是每个目录指令,Apache 从 RewriteRule
URI 模式中剥离 当前目录路径 。
终于写出了htaccess的代码,在http://htaccess.madewithlove.be/中进行了测试,发现是正确的。
在此 http://htaccess.madewithlove.be/ 中重写 URL 的方式有效
但是当我在我的网站中使用相同的 htaccess 代码时,它不起作用。
新 URL http://192.168.1.190/qjyii2/yii2dev3/frontend/web/login.php 实际 URL http://192.168.1.190/qjyii2/yii2dev3/frontend/web/index.php?r=site/login
Htaccess 代码
RewriteEngine On
RewriteRule ^qjyii2/yii2dev3/frontend/web/([^/]*)\.php$ /qjyii2/yii2dev3/frontend/web/index.php?r=site/ [L]
我的 mod_rewrite 在服务器上运行良好。我确实把这个 htaccess 放在 /www/qjyii2/yii2dev3/ 下,但它不起作用。非常感谢任何帮助。
如果您将其放在 /www/qjyii2/yii2dev3/.htaccess
中,则使用此代码:
RewriteEngine On
RewriteBase /www/qjyii2/yii2dev3/
RewriteRule ^(frontend/web)/([^/]*)\.php$ /index.php?r=site/ [L,NC,QSA]
.htaccess
是每个目录指令,Apache 从 RewriteRule
URI 模式中剥离 当前目录路径 。