Peter Knight

htaccess redirect

Recommended Posts

I have a single Processwire install with two domains pointing to it.


  • which is the "proper domain" and won't be live for a few months
  • which needs to go live immediately but just point to a sub-page

Is there a way with .htaccess to know when the site is being accessed through, keep that address is the browser bar and redirect to

To give a little context, a part of the in-progress needs to be accessible immediately and we've registered that temporary and pointed it at the same site.

The key here is to only do that redirect when is the source request. Otherwise I guess I'd use Jumplinks etc



Share this post

Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By benbyf
      Sure this has been asked a million times but cant find a simple answer.
      Trying to set the page to redirect to after login in the front end - i.e. not on the admin login page.
      some reason this works for super users but not normal users redirecting to a page which is viewable by members not guest role users.
      $showLoginError = false; if($input->post->user && $input->post->pass) { $username = $sanitizer->username($input->post->user); $pass = $input->post->pass; try { $session->login($username, $pass); // redirect user $session->redirect("/events/"); } catch (\Exception $e) { $showLoginError = true; } }  
    • By joelplambeck
      Hi Guys,
      I'm trying to do my first migration to the customers existing server (IIS 10) . I ran the site as a subdirectory on my website for test purposes (everything works fine).
      Following the tutorial of Joss, I tryed the site on a local xampp server to make sure, it also works on a root directory. So far so good, everything works.
      Now I moved the files (from the xampp) to the customers server. The root/index page is shown but for every subpage i get 404 Errors...
      Hence I followed the troubleshooting guide for not working URLs:
      On the first sight, the .htaccess file is not recognized, therefore I contacted the host support. They said, it is recognized but not all modules are supported in the processwire .htaccess file. I did the "öalskjfdoal" test in the .htaccess file and didn't get a 500 Error.... BUT the rewrite rule from the hosts support, to proof the file is read, DID work... The support claims, they do not provide debugging... so basically the .htaccess file is recognized and working, but not throwing any errors (for whatever reason).
      Working rewrite rule (from support):
      RewriteEngine On RewriteBase / RewriteRule ^test\.asp$ index.html [NC,L] RewriteRule ^test\.html$ konzept.html [NC,L] RewriteRule ^test2\.html$ team.html [NC,L] The support said, a couple modules are not supported in the htaccess file, the supported ones are listed here: (I think mod_rewrite is supported)
      As I do not completely understand what exactly is happening in the htaccess file, I'm stuck. I tried all suggestions I found regarding this topic on the forum, but none of them solved the problem.
    • By Roych
      I need some help with redirecting. I have create a template called (redirect) and AssistedURL field called (redirect_link) for redirecting a page if necessary.
      In template I've added:
      <?php if($page->redirect_link) $session->redirect($page->redirect_link); ?> redirect is working, but is it possible to create a link non clickable also, maybe with placing # for link? If I place # now it gives the whole link of the site with /# at the end and gives blank page. So placing (#) would disable a link totaly or something.
      Hope u understand what I mean
      Thank you
    • By rolisx
      Hi Guys,
      Just finished a website locally and wanted to upload it on the webserver of my customer. I got a server 500 error. Now, the guidelines of the hoster ( does not allow "Options" in the htaccess-file. So, when I uncomment these:
      Options -Indexes
      Options +FollowSymLinks
      the site is visible, but the content won't show and no links are available. Not sure if I need the Symlinks-part but I guess I need a workaround for the Index-part. Can anybody help here? I need the website up and running asap....
    • By suntrop
      Sometimes I need pages in the site tree that are basically just a reference to another page – to redirect to the original page or display the same content under the new page url.
      I was surprised I couldn't find anything like that in the forum or as a module already. However, there is a new module by @Robin S but not exactly what I need.
      Home News Press Newsroom Media Services About Newsroom (virtual page for /news/newsroom/) Contact Example I: The page /about/newsroom/ should act as /news/newsroom/ – so, wehen I loop all pages for a sitemap both pages should have the URL /news/newsroom/.
      Example II: Another example (not often used) would be tu display the exact same content on /about/newsroom/ – although the page itself has no content on its own.
      Those examples don't have much in common, but they are just virtual or fake pages in the site tree.
      While the second one should be an easy task with wireRenderFile(), the first example isn't quite obvious to me. I think I have to use hooks and I have no idea where to start. I really appreciate you guys come up with a solution for everything, but I need to learn this myself  So just some hints to start would be great!
      Do I put the code into a module or some of the _init.php, ready.php etc. files? Or do I have to use a template file (e.g. virtual-page.php)? When I look into Captain Hook  – how do I find the appropriate point to hook into? (/wire/core/ Page.php and loaded()?) Do I need to create/manipulate each field separately (path, title, summary)? Sorry for the long read