dquv73115 2013-10-05 06:15
浏览 48
已采纳

部署的Yii应用程序不会正确地为域子文件夹构建URL

EDIT (a solution): In the end, the problem wasn't with yii configuration or with the virtual server, but with the main server. I contacted the server administrator and the issue was solved by changing the URL to which the main server (where mi virtual server is hosted into) redirects the requests, to append the string containing the virtual folder's name.

I'm not sure if this was the best solution, but it's a solution. So if you face a similar problem, you might want to contact your server administrator.

Here's the detail of the original problem and some of the options I tried, just for reference:

I've been developing a Yii application for a couple of weeks, and it works perfectly on my local server, but I'm having some troubles to make the URLs work properly when deploying the app.

In the server, I have an structure similar to this:

/www/MyApp/(index.php, protected folder, etc)
/www/yii (the framework is located here)

And I can access my website using an URL like this:

www.somedomain.ac/VirtualFolder/MyApp

My problem is that all the links generated by yii are pointed to (for example):

www.somedomain.ac/MyApp/index.php?r=controller/index 

instead of

www.somedomain.ac/VirtualFolder/MyApp/index.php?r=controller/index 

I tried modifying the urlManager section at the configuration, and for some reason adding these rules:

'../../VirtualFolder/MyApp/index.php/'.'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'../../VirtualFolder/MyApp/index.php/'.'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

make some of the builded URLs point to the proper action, with the complete URL, but still, other ones won't work (all the ones that send a form to the server).

I've been trying other solutions to similar problems during a couple of days (like changing the app's basepath, adding "VirtualFolder" to it) but they don't seem to work.

Suggestions on how to solve the problem will be very appreciated.

Thanks.

============================================

EDIT: I am trying to do it with an .htaccess file like this:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} somedomain.ac$ [NC]
RewriteCond %{HTTP_HOST} !VirtualFolder
RewriteRule ^(.*)$ http://somedomain.ac/VirtualFolder/$1 [R=301,L]

And I copied it to my web root, but not working yet. Also tried copying it to MyApp/protected folder and directly into MyApp. Am I missing something?

Thanks.

  • 写回答

2条回答 默认 最新

  • douzuqin3467 2014-01-12 15:55
    关注

    (how the problem was solved): In the end, the problem wasn't with yii configuration or with the virtual server, but with the main server. I contacted the server administrator and the issue was solved by changing the URL to which the main server (where my virtual server is hosted into) redirects the requests, to include the string containing the virtual folder's name.

    So if you face a similar problem, you might want to contact your server administrator.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录