d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Silent Redirect Apache Url Rewrite > Yep That Bit**
Add Reply New Topic New Poll
Member
Posts: 6,314
Joined: Feb 15 2007
Gold: 852.00
Aug 15 2013 10:18pm
I need a "silent redirection" in with apache url rewrite mod

I have a redirection structure mapping fake directories to GET vars ending with a R=301

working with 0 to 5 variables that are unpredictables
(throws 404 header and custom 404page when PHP fails to find something associated)

always redirecting to the same PHP doc that handles it
using an absolute path

examples:

site.com ==> site.com (in fact redirects to default welcome page site.com/default which is then redirected)
site.com/foo ==> site.com?index=foo
site.com/foo/bar ==> site.com?index=foo&var1=bar
site.com/foo/bar/a ==> site.com?index=foo&var1=bar&var2=a
site.com/foo/bar/a/b ==> site.com?index=foo&var1=bar&var2=a&var3=b
site.com/foo/bar/a/b/c ==> site.com?index=foo&var1=bar&var2=a&var3=b&var4=c

after redirect is done I change user url back to the nice site.com/foo/bar version with js pushState (that part would be off with a hidden redirection)

*tricky : All the navigation is done via absolute links that are handled in an iframe

So, when I try using some relative path (and no R=301) in order to silently redirect, it falls in a redirection loop in the iframe

if you have any idea what to do

This post was edited by Beejee on Aug 15 2013 10:28pm
Member
Posts: 6,314
Joined: Feb 15 2007
Gold: 852.00
Aug 16 2013 12:16pm
I have fixed the problem

part of the root .htaccess code
Code
RewriteCond %{REQUEST_URI} /([^/]+)/([^/]+)
RewriteRule .* index.php?index=%1&v1=%2  [END,L]

RewriteCond %{REQUEST_URI} /([^/]+)
RewriteRule ^(.*)$ index.php?index=%1  [END,L]


already had the END flag, that wasnt the problem

I had turned off sub folder RewriteEngine to off
where was localised the iframe used as content

So, I had to setup an .htaccess for this one as well
with about the same rules, as the parameters sent to that iframe were kept unformated (ex: /index/foo/bar instead of ?index=index&a=foo&b=bar)

Now I just have to 301 redirect any
?index=index&a=foo&b=bar
to /index/foo/bar
in order to avoid duplicate content
so it gets internally rewrote back to ?index=index&a=foo&b=bar

So finaly google (and others) will crawl my nice addresses,
so I could finaly turn on progressive content showing (or whatever how we call that when the first print is all PHP done server side without ajax or browser js, and then further navigation being done witj js ajax and inside iframes, if those are available)
just right enough for the crawlers

So yeah 1st english aint my first language and 2nd im neither a daylife programming worker anywhere nor do I have any real school degree in that
thus if you want me to explain furthermore anything and clarify something, just let me know,
pretty sure I could help out someone out there!


This post was edited by Beejee on Aug 16 2013 12:18pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll