将我的CakePHP v2.2应用程序从linux服务器复制到Azure应用服务以进行开发/测试。 我知道.htaccess不起作用,所以我在每个文件夹\和\app\ \app\webroot\添加了一个web.config。 该网站的根目录工作,主页加载,从SQL读取数据,CSS和JS加载。 CSS文件托管在\app\webroot\css ,但通过example.com\css\file.css访问,所以我假设某种重写正在工作。
问题是去页面时,即example.com/about ,我得到错误The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
我已经看到了大部分文章,如果不是所有关于在IIS上托管的帖子,我想我的web.configs也在那里。 我错过了什么?
web.config在\
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="rule1A" stopProcessing="true"> <match url="^$" /> <action type="Rewrite" url="app/webroot/" /> </rule> <rule name="rule2A" stopProcessing="true"> <match url="(.*)" ignoreCase="false" /> <action type="Rewrite" url="app/webroot/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>\app\ web.config
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.web> <customErrors mode="Off"/> </system.web> <system.webServer> <rewrite> <rules> <rule name="rule 1A" stopProcessing="true"> <match url="^$" /> <action type="Rewrite" url="webroot/" /> </rule> <rule name="rule 2A" stopProcessing="true"> <match url="(.*)" /> <action type="Rewrite" url="webroot/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>web.config in \app\webroot\
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="CakePHP" stopProcessing="true"> <match url="^(.*)$" ignoreCase="true" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="index.php" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> </configuration>Copied my CakePHP v2.2 app from a linux server to Azure App Service for dev/testing. I get that .htaccess won't work, so I've added a web.config in each folder \ & \app\ & \app\webroot\. The root of the site works, the home page loads, reads data form SQL, the CSS and JS loads. CSS files are hosted in \app\webroot\css, but accessed via example.com\css\file.css, so I assume some sort of rewrite is working.
The issue is when going to a page, i.e. example.com/about, I get the error The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
I've seen most if not all posts on here about hosting this on IIS, and again I think my web.configs are there. What am I missing?
web.config in \
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="rule1A" stopProcessing="true"> <match url="^$" /> <action type="Rewrite" url="app/webroot/" /> </rule> <rule name="rule2A" stopProcessing="true"> <match url="(.*)" ignoreCase="false" /> <action type="Rewrite" url="app/webroot/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>web.config in \app\
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.web> <customErrors mode="Off"/> </system.web> <system.webServer> <rewrite> <rules> <rule name="rule 1A" stopProcessing="true"> <match url="^$" /> <action type="Rewrite" url="webroot/" /> </rule> <rule name="rule 2A" stopProcessing="true"> <match url="(.*)" /> <action type="Rewrite" url="webroot/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>web.config in \app\webroot\
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="CakePHP" stopProcessing="true"> <match url="^(.*)$" ignoreCase="true" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="index.php" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> </configuration>最满意答案
修复! 再次发现这篇文章,并更新了\ web.config,并从其他两个位置删除了web.configs。 奇迹般有效!
https://book.cakephp.org/2.0/en/installation/url-rewriting.html#url-rewrites-on-iis7-windows-hosts
web.config在\
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Rewrite requests to test.php" stopProcessing="true"> <match url="^test.php(.*)$" ignoreCase="false" /> <action type="Rewrite" url="app/webroot/test.php{R:1}" /> </rule> <rule name="Exclude direct access to app/webroot/*" stopProcessing="true"> <match url="^app/webroot/(.*)$" ignoreCase="false" /> <action type="None" /> </rule> <rule name="Rewrite routed access to assets(img, css, files, js, favicon)" stopProcessing="true"> <match url="^(img|css|files|js|favicon.ico)(.*)$" /> <action type="Rewrite" url="app/webroot/{R:1}{R:2}" appendQueryString="false" /> </rule> <rule name="Rewrite requested file/folder to index.php" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <action type="Rewrite" url="index.php" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> </configuration>Fixed it! Found this article again, and updated just the web.config at \ and removed the web.configs from the other two locations. Works like a charm!
https://book.cakephp.org/2.0/en/installation/url-rewriting.html#url-rewrites-on-iis7-windows-hosts
web.config in \
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Rewrite requests to test.php" stopProcessing="true"> <match url="^test.php(.*)$" ignoreCase="false" /> <action type="Rewrite" url="app/webroot/test.php{R:1}" /> </rule> <rule name="Exclude direct access to app/webroot/*" stopProcessing="true"> <match url="^app/webroot/(.*)$" ignoreCase="false" /> <action type="None" /> </rule> <rule name="Rewrite routed access to assets(img, css, files, js, favicon)" stopProcessing="true"> <match url="^(img|css|files|js|favicon.ico)(.*)$" /> <action type="Rewrite" url="app/webroot/{R:1}{R:2}" appendQueryString="false" /> </rule> <rule name="Rewrite requested file/folder to index.php" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <action type="Rewrite" url="index.php" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> </configuration>更多推荐
发布评论