简体   繁体   English

.HTACCESS RewriteRule无法按预期工作

[英].HTACCESS RewriteRule not working as expected

I have a magento website, that is currently operating. 我有一个magento网站,目前正在运行。 Within a subfolder of this site, I have placed a 3rd party application that also has its own HTACCESS file to handle routing for its application. 在此站点的子文件夹中,我放置了一个第三方应用程序,该应用程序也有自己的HTACCESS文件来处理其应用程序的路由。

When I access the folder http://example.com/somefolder the screen I expect shows up, but when I navigate to http://example.com/somefolder/newroute , I instead land on a magento 404 screen. 当我访问文件夹http://example.com/somefolder时 ,会显示我期望的屏幕,但是当我导航至http://example.com/somefolder/newroute时 ,我会转而进入magento 404屏幕。

I have traced this to the magento htaccess file, in all cases, unlesss the path physically exists the rewriterule will always send the request to the index.php - this explains why Im getting there. 在所有情况下,我都将此跟踪到magento htaccess文件中,除非该路径实际存在,否则重写器将始终将请求发送到index.php-这解释了为什么我到达那里。

To fix this issue, I wrote a little rewriterule which I placed in the htaccess file of the magento store. 为了解决此问题,我编写了一个小重写器,将其放在magento商店的htaccess文件中。 The goal was to add an exception to any request that came through and contained any reference to my subfolder. 目的是向所有通过并包含对我的子文件夹的引用的请求添加一个例外。 The thought is now it should hit the path its supposed, then hit the htaccess file, and then route me to where IM supposed to be in this other application. 现在的想法是,它应该按其原先的路径运行,然后按htaccess文件,然后将我路由到该其他应用程序中应位于IM的位置。 Unfortunately it doesnt seem to work, after adding the rule I end up the same place - magento. 不幸的是,它似乎没有用,在添加了规则之后,我最终停留在同一个地方-magento。

Here is what I've written: 这是我写的:

RewriteRule ^(.*somefolder.*)$ $1 [L]

Im not sure what could be going wrong, as I think the approach seems pretty straight forward. 我不确定会出什么问题,因为我认为这种方法似乎很简单。 Any ideas on how to remedy this situation? 关于如何纠正这种情况有什么想法?

Thanks. 谢谢。

这是您的简单答案。我在我的网站上也使用过。

    RewriteCond %{REQUEST_URI} !^/(yourfoldernameHERE)$

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

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