简体   繁体   English

apache RewriteRule从根目录到子目录缺少链接

[英]apache RewriteRule from root to subdirectory missing links

i made a RewriteRule in my .htaccess to redirect the following pattern www.mysite.com/s/1 to www.mysite.com/site/core/gallery.php?s=1, the redirect works but the page loads with missing links how can i fix this 我在.htaccess中创建了一个RewriteRule来将以下模式www.mysite.com/s/1重定向到www.mysite.com/site/core/gallery.php?s=1,重定向有效,但页面加载丢失链接我该如何解决

this is my rewrite rule: 这是我的重写规则:

RewriteEngine On RewriteEngine开

RewriteRule ^s/([A-Za-z0-9-]+)/?$ /site/core/gallery.php?s=$1 [NC,L] # Handle scene requests RewriteRule ^ s /([[A-Za-z0-9-] +)/?$ /site/core/gallery.php?s=$1 [NC,L]#处理场景请求

Most likely what you refer to with the expression "with missing links" is that objects referred to via links inside that page are not loaded once the page itself is loaded. 使用“缺少链接”这个表达式所指的最有可能的是,一旦页面本身被加载,该页面内通过链接引用的对象就不会被加载。 This can have a number of reasons, since you do not provide any details we have to guess ... 这可能有多种原因,因为您没有提供任何细节,我们不得不猜测 ...

Most likely the reason is that your "links" are of wrong format, absolute instead of relative. 最可能的原因是您的“链接”格式错误,是绝对格式,而不是相对格式。 Take a look at the format of the links that are not loaded. 看一下未加载的链接的格式。 Probably they are either full urls including protocol scheme and server name or an absolut path (starting with a / ). 它们可能是包含协议方案和服务器名称的完整URL,也可能是绝对路径(以/开头)。 Since you redirect the request but most likely not requests to those embedded links things don't match. 由于您重定向了请求,但很可能没有将请求重定向到那些嵌入式链接,因此不匹配。

Have a try changing the links to relative format ( not starting with a leading / ), so that the referenced objects can be found relative to the pages position in the namespace of the server. 尝试将链接更改为相对格式( 而不以前导/开头),以便可以相对于服务器名称空间中的页面位置找到引用的对象。

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

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