logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Map or redirect to path based on referer
Author
chelyapov



Joined: 29 May 2018
Posts: 2
Location: USA, Honolulu

PostPosted: Tue 29 May '18 8:19    Post subject: Map or redirect to path based on referer Reply with quote

I've been trying to figure out a solution to this problem. I want to create a publicly accessible staging/dev site, but there are many absolute URLs being used throughout the site. My colleague says we have to make all the URLs relative before we can launch this site, but I keep thinking that there must be away to configure the server or write a script that would take care of this for us.

I'm using Apache 2.4.29 on Ubuntu 16.04, with PHP 5.6.36 and MySQL 5.7.22.

I created rewrite rules in the VirtualHost and set environment variables to indicate if I'm on the staging site or the live site. I also added an auto_prepend_file to my php.ini that could create a redirect based on a variable's value. But I didn't quite get it working the way I want it. I can get it to load just dev.example.org correctly, but clicking on an absolute link to www.example.org either takes me to the live site or, when I try to use the redirect approach, fails with too many redirects.

I'm thinking that this would be what I want:


Is this possible to do? If we weren't using PHP exec files, then I could just use Javascript to replace all the domain names. I don't know if it's possible to dynamically rewrite a PHP file with a little script so that the file remains intact for it to be pushed to the live site as is.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Wed 30 May '18 17:59    Post subject: Reply with quote

you can use mod_sed[1]




[1] https://httpd.apache.org/docs/trunk/mod/mod_sed.html
Back to top
chelyapov



Joined: 29 May 2018
Posts: 2
Location: USA, Honolulu

PostPosted: Thu 31 May '18 7:44    Post subject: Reply with quote

I will give this a try, thank you!
Back to top


Reply to topic   Topic: Map or redirect to path based on referer View previous topic :: View next topic
Post new topic   Forum Index -> Apache