JimWorld Forums: #REDIRECT syntax



Posted By: usanyou ()
Posted On: 05/11/2007 05:23 pm


is someone able to explain the format for using the #REDIRECT command? i'm confused about a couple of things:

1) in the example, #REDIRECT [targetpage] ... do i need to include the file extension?

2) how exactly do i trigger this re-direct link? i had assumed the following:

- create a new 1-line file called, "fileA"
- link to "fileA" from say, my home page
- "fileA" would automatically load the targetpage coded into the #REDIRECT command

i must be missing something because when i click on the link, my re-direct page doesn't lead anywhere -- i only see the 1-line code of the page i just created.

thx in advance ....

PS -- i'm not a programmer by any stretch so plz choose your words carefully smile


Posted By: formerskeptic ()
Posted On: 05/18/2007 12:44 am

There are many ways to do this. Here are just a couple of simple ones.

To redirect from "fileA" to your home page, place either one of the methods (below) inside fileA's header tags:

Method 1:

Code: [copy]





Method 2:

Code: [copy]





Hope this helps :)


Posted By: dudibob ()
Posted On: 05/18/2007 02:54 am

also if you use either of those redirects, robots.txt them because they are really un-SE friendly wink


Posted By: usanyou ()
Posted On: 05/19/2007 10:47 am


thx for this guys, but .. i've since discovered that the #redirect i was asking about is an internal command << not quite the result i was looking for.

however .. i am familiar with the html refresh and javascript options, BUT ...

am now trying to use the htaccess file and am having little luck. are either of you able to field some suggestions if i provide a little more detail? ...

thx in advance .. smile



Posted By: david68 ()
Posted On: 05/20/2007 06:19 am

Google "htaccess redirect"

(htaccess)
Redirect 301 /oldpage.html http:// www.yoursite.com/newpage.html

(all one line, no space between http:// and www - the forum makes it a link if I didn't put the space there)

You can also use "rewrite" but it's more complicated.




Posted By: usanyou ()
Posted On: 05/20/2007 09:16 am

yes - i've moved on to the htaccess file but that's not working either. it will redirect my page fine, but the affiliate link that i'm trying to hide still shows in the URL.

i'm using the same syntax that you used, david68 and am thinking that there must be some other attributes in some other files that ignore htaccess unless i set them accordingly. otherwise ... not sure why it isn't working ...?

suggestions?

thx for your continued help smile


Posted By: g1smd (Moderator)
Posted On: 05/20/2007 09:21 am

You need an Internal Rewrite rather than an External Redirect if the URL in the browser is not supposed to change.


Posted By: usanyou ()
Posted On: 05/20/2007 07:44 pm


ok um ...

by "Internal Rewrite," can i assume that you are talking about the htaccess file? then, what is the "External Redirect?" do i still use the htaccess for that?

i will give you a specific example of what i would like to accomplish:

1. i created a dedicated folder ("temp"wink with multiple sub-folders, each with their own affiliate link reflected in the sub-folder's index file

2. i want to redirect each subfolder's index page directly to the sales page without revealing my affiliate link in the URL

3. the syntax i have been using (with the htaccess from the "temp" folder):

redirect 302 /[filename] http://[affiliatelink]

the redirect works, but the affiliate link still displays in the address bar and everything i have read, including a video tutorial, shows the URL changing to the domain of the sales page (eg. www.productA.com)

if this syntax represents an "external redirect" and that's not what i should be doing, what would be the correct syntax for the "internal rewrite?"

what is the difference?

thx again ...


Posted By: formerskeptic ()
Posted On: 05/20/2007 11:44 pm

Try this.

[ Message was edited by: formerskeptic 05/21/2007 12:25 am ]




Posted By: g1smd (Moderator)
Posted On: 05/21/2007 04:34 pm

An external redirect sends a code like "301" back to the web browser along with the URL of the new location where the content is now located. The browser then sends a new request for that new URL.

An internal rewrite takes requested URL "A" from the browser but then actually fetches the content from internal URL "B". The browser doesn't get to see the value for "B" and will never know that it exists.

URL "B" is directly accessible to users but should never be linked to from any of your pages, otherwise you create a Duplicate Content issue. In most cases where you rewrite A to B, you also need to redirect B to A. This does NOT cause a loop, because one is a redirect and the other is a rewrite.



Posted By: usanyou ()
Posted On: 05/22/2007 11:59 am


ok then ...

it sounds like both produce similar results - even that BOTH methods will display the URL of site "B," which is what i want to see (not my affiliate link).

so, i am still unclear about the application of either (sorry - i'm slow).

what is the syntax for the internal rewrite?
"ch_mod" or "mod_rewrite"


URL "B" is directly accessible to users but should never be linked to from any of your pages, otherwise you create a Duplicate Content issue.


So ... does this mean that i can only refer to url "B" in my masking efforts?


In most cases where you rewrite A to B, you also need to redirect B to A. This does NOT cause a loop, because one is a redirect and the other is a rewrite.


i'm not getting my head around that. again, i'm not seeing the difference if both do the same thing.



i looked at your resource, formerskeptic (thx). however, i am already applying the exact redirect 301 syntax and as it's not giving me the desired results. redirect works, but affiliate link is displayed.

also, the section on "Hiding affiliate links using mod_rewrite" is a little vague to me (i'll need to brush up on that). it sounds to me like the thing to do is to use this syntax to redirect the contents of a folder to site "B" - which is what i'm wanting to do. i just thought that it could be done using "redirect 301." again, not getting what the difference is.


i hate to test your guys' patience, but are either of you able to specifically provide a syntax example to resolve my specific need from above (2 posts ago)?

"redirect" isn't working. do i need "ch_mod" or "mod_rewrite" or something else?

hopefully, it isn't too foggy but i can try to simplify if necessary.



thx for your patience!!!



Posted By: g1smd (Moderator)
Posted On: 05/22/2007 03:12 pm

A redirect produces an external 301 or 302 code.

A rewrite is invisible to the end user.



The difference in syntax, therefore, is simply the presence or absence of an [R] in the code.

So, [R] and [R=302] both produce a 302 redirect and [R=301] produces a 301 redirect.



They are both used with the

RewriteCond ...
RewriteRule ...


syntax.


Posted By: formerskeptic ()
Posted On: 05/27/2007 10:51 pm

The only other explanation to your problem, I think, would have to do with your host. If you're using a shared host, chances are they've probably put some kind of block on their (apache) config file to restrict any dynamic functions. I could be wrong but just check with your host.

Had a similar problem like this once & when I asked the host why I can't redirect using .htaccess, they pretty much had no idea what I was talking about. Thats another thing, make sure you use a compitent host who knows about server configurations.

If you're on a dedicated server or virtual server, then you should pretty much have unlimitted access to all the resources.

If you still can't get it to work, I'd suggest a redirect script. Php, asp, etc.


Posted By: usanyou ()
Posted On: 05/28/2007 09:35 am


i think this is the stage i'm at - incompetent hosting!

i am so-o frustrated with the run-around i've rec'd from them. it's bad enough that i have to wait ~3 minutes for every reply, but the best advice i've rec'd is links to their forum that have absolutely nothing to do with my questions, until eventually, i am told that it is a scripting problem and they are only available to help with hosting problems -- *Geesh!!*

i ran a phpinfo on my domain and saw no added modules, let alone any apache references, although they assure me that the module is enabled by default. to prove that it was available on my domain, they told me to do phpinfo on THEIR domain. naturally, it showed the apache mod_rewrite module ... on their domain.

am i an idiot? ... am i the only one who's inquired into this subject with this host? ...

i apologize for venting, but it is an ongoing (3 weeks+ now). when i don't have an answer for someone, i find it so much easier to admit that i don't know, and offer to find out. how hard is that?

i apologize for venting. i'm glad for your recent post though, because for me, it verifies that there is an outside chance it's NOT just me. i think i've read every online tutorial that's out there (apache mod_rewrite, redirects, url rewriting, robots.txt, & other SEO implications) and i know i'm slow, but for Heaven's sake, i think i can put 2 and 2 together long enough to determine whether or not i am completely daft.

this thread has introduced me to the differences between internal and external redirects and the overall nuances with redirects. THANX g1smd as well!

one last request ... can any of you please recommend a knowledgeable, reputable hosting service?

thx in advance!

PS
i promise i will be in a better mood next time.....


Posted By: formerskeptic ()
Posted On: 05/28/2007 10:04 pm

i apologize for venting
No need. We've been there too wink

can any of you please recommend a knowledgeable, reputable hosting service?
Here's an old thread that'll get you started on the right track smile



Posted By: david68 ()
Posted On: 05/29/2007 08:22 am

I use serverheaven dot NET - very cheap prices but really good hosting - and I know it allows internal and external redirects as I use both! Of course it depends on how big your site is if this is a practical solution.

RE: support tickets - most hosts won't help you with syntax, they only worry about if the server is running properly and has the modules/features you need installed. SH is pretty good about adding stuff for you if it's not there as long as it's not a security risk (some mods are). The owner wants it to be RELIABLE for his users.

(their homepage isn't accurate - click on signup and it'll show the prices - visit ...net/forums for more info - I'm a moderator there)


Posted By: usanyou ()
Posted On: 05/31/2007 08:45 pm


thx for the hosting links. am still reviewing.

am still trying variations of code for rewriting URLS -- no luck.

very frustrated!

....

...


Posted By: david68 ()
Posted On: 06/01/2007 07:30 am

To redirect oldfile to newfile location...

RewriteEngine On #use this only 1 time else error 500
RewriteRule ^oldfile.html$ /newfolder/newfile.html [L]

I don't know how/why it works but it does smile
(it doesn't use RewriteCond)

or

redirect permanent /folder http://newurl.com

Google "htaccess rewriterule" for more info.





JimWorld Forums © 1996 - 2004 .... iWeb Technology, Jimworld.com