homepage Welcome to WebmasterWorld Guest from 54.196.196.62
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
redirect to text version!
help!
ahmedtheking




msg:1286542
 12:07 pm on Jun 12, 2004 (gmt 0)

ok, ive got my text version of my site up and running, but, the link to it goes to the homepage of the text version, eg, say you're looking at my client list and you want to see it in the text version, you click text only and it sends you to the text version homepage, how annoying!

so then i thought, why dont i create a cgi script or include a php script within my html docs that will get the url from my root domain (www.example.co.uk), add '/text/' to it and then write. this means, when the client is on the client page, currently at www.example.co.uk/clients/index.html and they click text only, this means the cgi/php script will add '/text/' into the url so we get www.example.co.uk/TEXT/clients/index.html.

what an idea! but one big problem, i dont have the foggiest about perl and cgi and just learing the basics of php! is there anyone who can help me?ive had a go at messing around with perl but i havnt succeeded! its not as 'experimental' as html and javascript!

please help! or atleast teach me! cheers! :D

[edited by: jatar_k at 5:19 pm (utc) on June 12, 2004]
[edit reason] generalized [/edit]

 

jatar_k




msg:1286543
 6:23 pm on Jun 13, 2004 (gmt 0)

Welcome to WebmasterWorld ahmedtheking,

all of your pages could contain an dynamic path and only include and link to the text pages instead of the regular pages.

Another thought is to have?type=text or some such var tacked onto the url if they select text only

then have some intelligence in your main template to alter base paths or not include images. It really depends on a lot of different things and is difficult to guess at the best approach for you.

I keep thinking also that you may need some way to make sure that spiders can't get at both versions of the page so there are no duplicate content problems.

corz




msg:1286544
 7:08 pm on Jun 13, 2004 (gmt 0)

this sort of this is easily acheived using mod_rewite

I have a text viewer script (php) that intercepts .txt requests and presents a cool formatted version instead, there's a link to a plain text version on that page too, or the user could (I guess) make the extension .text and also get the raw version (the php script just passes it through in this case) something like..


# this is the text viewer handler thingie..
RewriteEngine on
RewriteRule (.*)\.t(.*)xt /inc/textview.php?txtfile=/public/docs/$1.t$2xt [NC]

it should be possible to work it out from that.
full source code for the text viewer available onsite!

;o)
(or

ahmedtheking




msg:1286545
 3:24 pm on Jun 14, 2004 (gmt 0)

woah! totally new to php! could you just explain it to me please? im using dreamweaver so the coding should be easy!

corz




msg:1286546
 6:43 pm on Jun 14, 2004 (gmt 0)

okay, from the top..

First, it looks simply like your original link is incorrect, I mean, why doesn't the link itself have "/TEXT/" in it? then reuests would go straight into /TEXT/, not the homepage.

If, for some reason, that's not possible, you can get mod_rewrite to add the "/TEXT/" part for you. This goes in your .htaccess file, which is in the root of your site, probably..

RewriteEngine On
RewriteRule ^clients/(.*)/clients/text/$1 [NC]

(I haven't tested that!) but anyway, now you are sending clients to another html page! I thought the user was looking for a text version? Why not send them directly to a text version, instead of another index?

It would be easy enough to have php generate a correct link for you, so a page like..

http://www.example.co.uk/clients/somepage.html

could have a link on it like..

http://www.example.co.uk/text/clients/somepage.txt

which seems a better strategy, to me.

I don't understand the problem with the original link. Could you explain why it's not possible to just put the correct link on the original html page in the first place? Or is it?

;o)
(or

ahmedtheking




msg:1286547
 11:10 pm on Jun 14, 2004 (gmt 0)

ok, erm, where i use dreamweaver or any web author, you cannot have a dynamic link to a certain page. for example, say your viewing some clients at:

[example.co.uk...]

and you decide that you want to see the text version of the site. Where i had a link, 'text only', that would point to:

[example.co.uk...]

the text version homepage! so the person would have to navigate to the clients page:

[example.co.uk...]

BUT!

i have kinda found a solution to this problem, but only works one way!

I have made a javascript that will rite:

<script language="JavaScript" type="text/javascript">
document.write('<a href=/text');
document.write(location.pathname);
document.write(' title=The TEXT VERSION accesskey=h>Text Only</a>');
</script>

this means that it will rite a link to /text and the the root path, in this case clients/myf.html

so with this location.pathname, that can be done.

but, is there a way of going backwards? as in, is that a js command where i can alter that, or will i have to use that mod rewrite thing?

also, a prob with js is that some people will have it off, which is a prob cos they want to view the site with no js or anythin! can cgi/php/wotever/ help me over come this?

thanks for all your help! ill make u lot a free website if u want! :D

[edited by: jatar_k at 11:18 pm (utc) on June 14, 2004]
[edit reason] generalized urls [/edit]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved