New Domain ULR Rewriting with little extra feature

Posted on 2011-05-02
Last Modified: 2012-05-11
Hi y'all

There's 1 domain ( for example)
Let's suppose the original URL is:
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 webserver)

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

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,
the destination URL in the browser is,
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.
Question by:fario
    1 Comment
    LVL 1

    Accepted Solution

    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

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now