wordpress - How to prevent htaccess from rewriting urls on the redirected page which are the same as the url of the original page? -
*** note ****
please skip "update 9" highlighted below real question; below troubleshooting original issue find going on.
*** (previous title of question: "after rewriting image url htaccess, new page shows fine image redirect not display unless reload page?")
a strange thing occurring, maybe problem htaccess code.
here code:
rewritecond %{request_filename} .*jpg$|.*gif$|.*png$ [nc] rewritecond %{http_referer} !mysitee\.com [nc] rewriterule ([^/]*)\.(jpg|gif|png)$ http://mysitee.com/?attachment=$1
what change:
http://mysitee.com/wp-content/uploads/2015/10/myimage.jpg
to this:
http://mysitee.com/?attachment=myimage
the code works well, strange thing happens need fixed. using wordpress way.
the problem on new page, image on attachment page rewrite url go to, not display unless manually reload page.
perhaps has htaccess redirecting before http request display image happen?
here's happens on redirect:
but when manually press reload on page, image loads.
i did else, redirected post page after that, , same thing happens on post page - other images load fine, image redirected shows blank until manually reload page. it's not problem attachment page.
see, here happens when redirect post page same way:
as see, other images , content still loads, not image image redirect. again, if manually reload page, image loads.
it seems http request issue result of redirect, or maybe has asynchronous loading due redirect, or maybe htaccess code isn't written properly. can't sure.
i need display image after redirect. please help.
update -
here html code on redirect when image not loading:
<div class="attachment"> <a href="http://mysitee.com/mycategory/myimage/attachment/myimage/#main" rel="attachment"> <img width="600" height="896" src="http://mysitee.com/wp-content/uploads/2015/07/myimage.jpg" class="attachment-1200x1200" alt="myimage"> </a> </div>
and here html code when refresh page , image loads:
<div class="attachment"> <a href="http://mysitee.com/mycategory/myimage/attachment/myimage/#main" rel="attachment"> <img width="600" height="896" src="http://mysitee.com/wp-content/uploads/2015/07/myimage.jpg" class="attachment-1200x1200" alt="myimage"> </a> </div>
the code same makes me thing it's other html code causing issue.
update 2 -
i compared entire source code of webpage before , after reload, , 100% identical, not single character different.
update 3 -
i viewed error window under inspect element , there no page errors displaying. must internal issue not front end issue.
update 4 -
okay, here's interesting. when right click image isn't loading, "copy image" greyed out can still copy image url correct.
does help?
update 5 -
i tried add:
options +followsymlinks
to htaccess, had no effect.
update 6 -
i used tor access outside ip , different browser, see if issue local, issue not local, happens everywhere.
update 7 -
here interesting. in inspection window, navigated image , when right clicked image , opened in new tab, did not open image instead opened same attachment url. see screenshot:
update 8 -
here network inspection window:
i see requesting attachment url instead of image url. when reload page, shows image url showing attachment url in network inspection window. problem.
here screenshot of network inspection window when reload page loads image. see, it's different. problem lies, because htaccess redirect causing redirected image on new page load attachment url instead of image url until manually reload page.
------------------------------------------------------------------------------------------------
update 9 - (final question needs answered)
ok further debugging confirmed issue, although don't know how fix it. checked redirecting other url well, , image url requesting url instead of image url same.
so what's happening same url being redirected, htaccess rewriting url same image on new redirected page redirect.
for example:
for image:
http://mysitee.com/wp-content/uploads/2015/10/myimage.jpg
which, on page visit redirected via htaccess code @ beginning of question to:
http://mysitee.com/?attachment=myimage
, now, on page
http://mysitee.com/?attachment=myimage
contains original imagehttp://mysitee.com/wp-content/uploads/2015/10/myimage.jpg
,the htaccess rewriting image
http://mysitee.com/wp-content/uploads/2015/10/myimage.jpg
redirected urlhttp://mysitee.com/?attachment=myimage
.so in other words, simplify easier terms, let's make:
image-x
=http://mysitee.com/wp-content/uploads/2015/10/myimage.jpg
url-z
=http://mysitee.com/?attachment=myimage
so occurring whenever
image-x
redirectedurl-z
via htaccess, every instance ofimage-x
on pageurl-z
rewritten htaccess changing url ofimage-x
url-z
.see path below:
original url:
image-x
1. htaccess redirect causes redirecturl-z
2. on pageurl-z
, contains imageimage-x
3. since in same http request, htaccess rewrites url ofimage-x
in http request request url ofurl-z
put yet way, html server seeing this:
<div> <a href="#"> <img src="http://mysitee.com/?attachment=myimage"> </a> </div>
but server should seeing this:
<div> <a href="#"> <imgsrc="http://mysitee.com/wp-content/uploads/2015/07/myimage.jpg"> </a> </div>
so how fix htaccess not rewrite images on redirected url too?
please thank you
Comments
Post a Comment