does anyone have advice on how to approach this:

I have javascript text editors in my cms :
I need to allow client to add/edit his text, which has lots of internal site links while site is on development server

site will move to live server one day
mod_rewrite is converting static urls to dynamic

problem is when adding the internal links with the editor tool and what happens with mod-rewrite and browser

I can enter a nice simple:"/heresthepage.php?x=342"
(with or without leading slash)

but the browser gets confused and links are garbagised on output side

I could get client to add links preceded with a bit of php:

<?php echo $siteroot ?> /exciting-page/342

or I could ask him to prefix links with some random stuff:

!ZYX!/exciting-page/343

and do str_replaces to add a dynamic php variable on insert to db...

and then of course reverse them to put it back into editor

its a pita right now...
any advice on strategy would be much appreciated

    I'm not sure what you're getting at. When developing a site, I make it a specific requirement that all links be relative to the site root (i.e. every link MUST start with a leading slash). That way no matter what server running whatever OS will always link correctly (from the domain root).

    It would seem like when they're linking things up, you should just tell them to always use a forward slash in front of their URLs. You could also do what I did (which I can't publish because of work) and hack the WYSIWYG editor to show a drop-down list of "static" and "dynamic" site URLs that are available. Then they only have to choose the link destination, not write it out by hand (possibly with issues).

    If you're using TinyMCE, I'll give you a hint: plugins/advlink/js/advlink.js and plugins/advlink/advlink.htm are two of the three files you'll need to edit. The third is your general script where you invoke TinyMCE for the textarea. You'll also need a script to do the listing of all internal and dynamic links. It's not hard, but it can be time consuming.

      problem is that the dev server is not dedicated to that project alone - its my server with all my other projects and this one is buried three folders down so a simple forward slash does not work there

      and yes I am using TinyMCE but I need a quick fix really - maybe leave all the links till its uploaded to live server but before site is made live

        Well, there is the option to set up your server so that {subdomain}.mydomain.tld will point to your one apache instance, then you can use server aliases and one virtualhost to do what you want.

        For example, I have a development server at my house. I develop multiple projects at a time and each project has its own subdomain. Then the links I use which reference "/" work both in the development environment and the the live server. No differences in the code unless you specifically reference the domain.

        A sample virtualhost could be:

        <VirtualHost *:80>
            ServerName mydomain.tld
            ServerAlias *.mydomain.tld
        
        DocumentRoot /var/www/vhosts/&#37;1/httpdocs
        </VirtualHost>

        The "%1" in the DocumentRoot matches up to the first "." of the domain. So if you type "www.mydomain.tld" %1 would equate to "www". if you type "item.mydomain.tld" the %1 would equate to 'item". %2 would be "mydomain" and %3 would be "tld". So the document root would be "/var/www/item/httpdocs" or "/var/www/www/httpdocs".

        This way you could keep all your sites in multiple folders, but still view each as if it was its own domain.

        The other alternative is to set up one VirtualHost directive per project. But this can be annoying after a while.

          -hey - that's a brilliant tip - thanks - looks like the best answer though I dont know if I can do that as its a shared server (I can do most things.. so here's hoping)

          • I just never heard of that before, sometimes it really seems there's an infinite amount to know

          (I also probably need to set up tiny MCE to do a drop down in the url tool anyway .. some jobs are never ending )

            Write a Reply...