简体   繁体   English

htaccess重定向到子文件夹资源

[英]htaccess redirect to subfolders resources

I have a problem: 我有个问题:

I have to modify an application written in Zend 1 that was deployed to the domain root. 我必须修改用Zend 1编写的应用程序,该应用程序已部署到域根目录。 now to test it the customer gave me a root subfolder called [domain]/social 现在进行测试,客户给了我一个名为[domain] / social的根子文件夹

When I run it, I have a lot of problem because all paths are like "/resource", but in this case the fiddler show me that the request look for [domain]/resource ad not for [domain]/social/resource. 当我运行它时,我遇到了很多问题,因为所有路径都类似于“ / resource”,但是在这种情况下,提琴手向我展示了该请求针对[domain] / resource广告而不是[domain] / social / resource。

It happens with script sources, ajax urls, hrefs...all! 它发生在脚本源,ajax url,hrefs ...全部!

Is there a way to fix the problem? 有办法解决这个问题吗?

I am not quite familiar with Zend, but is there a main config file that sets the application root folder? 我对Zend不太熟悉,但是是否有一个主要的配置文件设置了应用程序的根文件夹? (Like joomla) You can modify that if it exists. (例如joomla)您可以修改它(如果存在)。

Other option would be to preg_match or str_replace all instances of the domain name in the code ( like when moving a Worpress site) but you should definately do that with a sample content not couple hundred pages). 另一个选择是在代码中preg_match或str_replace域名的所有实例(例如在移动Worpress网站时),但是您一定要使用不超过数百页的示例内容来做到这一点。

And here is a htaccess snippet as well: 这也是htaccess的代码段:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/social/$1 [R=301,L]

Be sure to put the htaccess under the development folder not under the root, oterwise you're facing issues. 确保将htaccess放在开发文件夹下而不是在根目录下,否则您将遇到问题。

I suggest cheking for a config file first. 我建议先检查配置文件。 Hope one of this helps! 希望其中之一可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM