Search code examples
.htaccessrelative-pathabsolute-pathphpbb

Changing RELATIVE path to ABSOLUTE path


I got these relative links in my phpbb forum which I'd like to replace with absolute links:

For example, in HTML the links are written like:

<a href="./viewforum.php?f=5">Bladiebla</a>
<a href="./memberlist.php?mode=viewprofile&u=63">Admin</a>

These are links on a domain calld e.g.: http:://www.foo.com

I'd like these links lead to another different domain:

http://www.example.org/viewforum.php?f=5
http://www.example.org/memberlist.php?mode=viewprofile&u=63

Is there any fast way of doing this using htaccess?

The htaccess should only account for /viewforum.php and /memberlist.php

(not site-wide!)


The problem is:

I have a forum on a subdomain (forum.example.com) which I scrape and show on the frontpage (example.com). Clicking the links in the scraped forum content however, because they are relative, lead me to places like: example.com/viewforum.php?f=5 (which does not excist) but I'd like them to lead to forum.example.com/viewforum.php?f=5... dunno if I'm clear enough..


Solution

  • No.

    I'm almost completely certain that you can't using just .htaccess, and if you could, it would be an incredibly messy regular-expression based system that you want to avoid at all costs.

    If you must change them, change them manually1 because if you end up doing it with a .htaccess file it will be a complete waste of processing power, too.


    1 Obviously, this doesn't actually have to be completely manual. You can do find and replace stuff - make sure to check the results, though. If the URL will change, then consider outputting it dynamically with PHP instead. Also, just drop the ./ part because it's useless.