matanoosh Posted January 12, 2008 Share Posted January 12, 2008 Hello everyone. I couldn't find the exact answer on similar threads; Apologies if the topic has been discussed too much before. I'm trying to use mod rewrite to achieve the following outcome: 1. Current situation: page URL: www.MyDomain.com/Football.html /images /includes both directories above reside on the web root directory. all references to them from football.html are relative (i.e. /images/pic.gif or /includes/header.html) 2. Desired situation: page URL: www.MyDomain.com/Games/Football /images /includes remain in the same place. All relative links within the page (football.html) should still point to www.MyDomain.com/link.html and NOT MyDomain.com/Games/Link (check out www.Backgammon.Org for the solution I'm after). Obviously, a single RewriteRule didn't do the job for me. Guys, I need your help. It's way over my head. How can I solve it? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
madmax Posted January 12, 2008 Share Posted January 12, 2008 From the information in scenario 1) I can't see why you'd have a problem with links in scenario 2). Again, from the information given, this would look merely like an HTML page-editing issue regarding how you've specified your links. If there's a problem then I think you've missed out some important information somewhere Also, I can't see how the backgammon site illustrates the problem :/ ??? Quote Link to comment Share on other sites More sharing options...
matanoosh Posted January 12, 2008 Author Share Posted January 12, 2008 thanks for the reply. 1. the backgammon site shows how I want to implement things. 2. currently, if I redirect mydomain.com/football.html to mydomain.com/games/football/, all the relative links within the html will bear the directory "/games". this means that all "included" header and footer links will now contain a "/games/link.html" instead of just "link.html". Also, the browser tried to obtain the include and image files from "/games" location which, of course, doesnt exist. perhaps I am indeed missing the point and not implementing it correctly. I tried to use directories and '../' referrals in the relative paths for all links and files ('../images/image.gif', '../includes/footer.html' etc) but the browser doesn't recognize them. If I'm able to make it work with '../', then I guess I can dismiss the mod rewrite issue and solve it more simply. any suggestions? Quote Link to comment Share on other sites More sharing options...
madmax Posted January 13, 2008 Share Posted January 13, 2008 I'm still flummoxed with some of this and I'm not sure I have the whole picture. What makes you sure it's the browser which has issues properly handling relative paths such as "../games" ? Which browser are you testing on and having problems with? Is it just one browser or all?. Do you have any test content live yet which others on here could check out ? Bear in mind that a simple answer to creating a fake root mapping for a given folder might be to use the Alias directive with a "/" prefix. This is how (or should be, how) your "/error/" pages work across all of the sites on any server. You can access /error/whatever.html from anywhere. Say you had one set of widgets (icons graphics) which you want to map as "root" you can declare an alias to a physical path. This may be a simpler solution than doing an awful lot of fiddling with page content and would make the content root-global across all sites you operate - and also make page-editing a lot easier. http://httpd.apache.org/docs/2.0/mod/mod_alias.html Linux...(fingers crossed the example is correct - I'm not a Linux expert) Alias /widgets /var/www/htdocs/content/widgets Win32 ... Alias /widgets "c:/www/htdocs/content/widgets" You could then access "/widgets/blue.gif" from any page on any site but browsing for resources during page editing might be problematic!. Depends how you generate your content. Then again... any solution offered might be wrong as I'm not entirely convinced that you're not making perhaps some wrong assumptions about the way browsers or HTML linking works. Worth checking... Try this http://www.w3.org/TR/html401/struct/links.html specifically http://www.w3.org/TR/html401/struct/links.html#h-12.4.1 (document base) If you are having problems with upward references then you might possibly have unintentionally blocked directory traversals with ".." elsewhere without realising the consequences - e.g. using mod_security or another security rewrite rule. Not aware of any browsers which would have problems handling upward directory traversals though. I can't recall the last time I purposely used "../" .. or ../ GO UP and append path (if you use this a lot you might consider using an Alias) <nothing> append to current base path / ROOT map content path to server root Is there anything specific on the back gammon site which illustrates an issue I can check? I would also recommend testing on serveral browsers esp IE, Firefox, Seamonkey etc. An awful lot of this advice would depend on what you find convenient and how you generate your pages. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.