Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

New Domain ULR Rewriting with little extra feature

Hi y'all

There's 1 domain (www.domain1.com for example)
Let's suppose the original URL is: http://www.domain1.com/view?product=1341342
I have no access to this webserver.

What i would like to obtain is the following kind of URL rewrite:
(I have access to the www.domain2.com webserver)

When the user goes to http://www.domain2.com/view?product=1341342 a php script should read the  "/view?product=1341342" part (for statistic purposes, i have the script for that) then redirect the location to http://www.domain1.com/view?product=1341342

In short, what i don't know how to implement is how to read the domain2 URL's product  and redirect the user to the domain1's right URL with a PHP file:

The originating URL is http://www.domain2.com/view?product=1341342,
the destination URL in the browser is http://www.domain1.com/view?product=1341342,
while redirecting PHP must take note of the product page.

Also (speaking about removing the domain from the URL) the product page URL could have a different name.
0
fario
Asked:
fario
1 Solution
 
farioAuthor Commented:
Ok i found the solution:

Since the new domains has no content (a part from the stats script), so i can use the 404 error to get the originating URL.

With this .htaccess rule i am able to pass the full originating URL to the url variable

RewriteRule ^/?(.*)$ /analyze.php?url=$1 [L]

Open in new window


Now i just need to create a php script that replace the domain2 with domain1 in the url variable, then redirects to the new location the browser.

Thanks anyway
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now