Community @ The Turning Gate

Support community for TTG plugins and products.

You are not logged in.

#1 2017-04-21 16:36:58

Terry
Member
From: United Kingdom
Registered: 2013-02-19
Posts: 66
Website

.htaccess redirect not working

Hi,

I want to redirect some of the old pages which are links on various sites from CE4 i.e services.php to the new page in backlight.

I tried putting in redirects in the .htaccess but backlight rewrite rules override them as add extra bits on, unfortunately I don't have the brain power to work it as to what is going on.

Does anyone have some pointers please big_smile

Thanks in advance,
Terry

Offline

#2 2017-04-21 20:26:43

charlie.choc
Member
From: Marietta, GA
Registered: 2014-01-09
Posts: 135
Website

Re: .htaccess redirect not working

Here is the .htaccess form my 'galleries' folder and my rewrite rules seem to work correctly:

---------------------------------------------------------------------------------------------

<IfModule mod_rewrite.c>
    RewriteEngine On
   
    # redirects for revised gallery structure

    RewriteRule ^smoky-mountains/(.*)$ /galleries/landscapes/smoky-mountains/$1 [R=301,NC,L]
    RewriteRule ^seashores-swamps-and-wetlands/(.*)$ /galleries/landscapes/seashores-swamps-and-wetlands/$1 [R=301,NC,L]
    RewriteRule ^great-plains-and-mountain-west/(.*)$ /galleries/landscapes/great-plains-and-mountain-west/$1 [R=301,NC,L]
    RewriteRule ^far-west/(.*)$ /galleries/landscapes/far-west/$1 [R=301,NC,L]
    RewriteRule ^fall-colors/(.*)$ /galleries/landscapes/fall-colors/$1 [R=301,NC,L]
    RewriteRule ^desert-southwest/(.*)$ /galleries/landscapes/desert-southwest/$1 [R=301,NC,L]

    # end redirects


    ############################################################################
    # Edit this section for servers using FastCGI

    # For FastCGI (or seeing the error message 'No input file specified.':
    # add # to the start of the next line
    RewriteBase /

    RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$

    # For FastCGI (or seeing the error message 'No input file specified.':
    # add # to the start of the next line and remove # from the line after)
    RewriteRule ^.*$ - [E=BASE:%2]
    #RewriteRule ^(.*)$ - [E=BASE:]

    ############################################################################


    RewriteRule ^(.*)$ - [E=QS:mod_rewrite=on]

    RewriteRule ^([^\/.]*)-single.php$ %{ENV:BASE}single.php?%{ENV:QS}&id=$1 [QSA,L]

    RewriteRule ^([^\/.]*).css$ %{ENV:BASE}index.php?%{ENV:QS}&extension=css&name=$1 [QSA,L]
    RewriteRule ^([^\/.]*).js$ %{ENV:BASE}index.php?%{ENV:QS}&extension=js&name=$1 [QSA,L]
    RewriteRule ^([^\/.]*).gif$ %{ENV:BASE}index.php?%{ENV:QS}&extension=gif&name=$1 [QSA,L]
    RewriteRule ^([^\/.]*).png$ %{ENV:BASE}index.php?%{ENV:QS}&extension=png&name=$1 [QSA,L]
    RewriteRule ^([^\/.]*).jpg$ %{ENV:BASE}index.php?%{ENV:QS}&extension=jpg&name=$1 [QSA,L]

    #RewriteCond %{QUERY_STRING} !mod_rewrite=on
    #RewriteRule ^index.php$ %{ENV:BASE}index.php?%{ENV:QS} [QSA,L]

    RewriteCond %{QUERY_STRING} !mod_rewrite=on
    RewriteRule ^mobile.php$ %{ENV:BASE}mobile.php?%{ENV:QS} [QSA,L]

    RewriteCond %{QUERY_STRING} !mod_rewrite=on
    RewriteRule ^(.*)download.php %{ENV:BASE}download.php?%{ENV:QS} [QSA,L]
   
    RewriteRule ^$ %{ENV:BASE}index.php?%{ENV:QS} [QSA,L]
   
    #RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule ^(.*)$ %{ENV:BASE}index.php?%{ENV:QS}&page=$1 [QSA,L]

</IfModule>

############################################################################
# To fix cross-origin font issues for non-Pages users, remove the preceding '#' on the next five lines:

#<IfModule mod_headers.c>
#    <FilesMatch "\.(eot|font.css|otf|ttc|ttf|woff)$">
#        Header set Access-Control-Allow-Origin "*"
#    </FilesMatch>
#</IfModule>

############################################################################

Offline

#3 2017-04-21 22:17:36

Terry
Member
From: United Kingdom
Registered: 2013-02-19
Posts: 66
Website

Re: .htaccess redirect not working

Thanks Charlie, still can't get it to work on the root. Not sure if it's because I'm trying to redirect a .php file rather than a directory. I can redirect from other directories fine.

Offline

#4 2017-04-21 22:27:23

charlie.choc
Member
From: Marietta, GA
Registered: 2014-01-09
Posts: 135
Website

Re: .htaccess redirect not working

Ah, I didn't read your post clearly. It might be simpler just to move the content from the CE4 pages to Backlight ones, that's what I did. Initially it's more work but simplifies maintenance down the road. Unless you are wanting to keep both CE4 and Backlight sites.

Offline

#5 2017-04-21 22:42:15

Terry
Member
From: United Kingdom
Registered: 2013-02-19
Posts: 66
Website

Re: .htaccess redirect not working

Yeah not quite that straight forward hmm ah well. Thanks for responding.

Offline

#6 2017-04-21 22:49:48

charlie.choc
Member
From: Marietta, GA
Registered: 2014-01-09
Posts: 135
Website

Re: .htaccess redirect not working

In your Backlight menu set can you not just specifiy the URL for your services php file?

Offline

#7 2017-04-22 00:06:51

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 623
Website

Re: .htaccess redirect not working

Following format should work:

Redirect 301 /old-page.html http://www.mydomain.com/new-page.html

Redirect 301 code is a permanent redirect. This means that search engines should update their internal database to always use the new location.


Daniel Leu | Photography   
DanielLeu.com

Just a user who loves to dive into techie stuff... and sometimes gets into trouble for that.

Offline

#8 2017-04-22 00:25:33

Terry
Member
From: United Kingdom
Registered: 2013-02-19
Posts: 66
Website

Re: .htaccess redirect not working

Yeah that doesn't work either. I'm sure it's because there is other code controlling redirects and they are conflicting.

.htaccess line

Redirect /galleries.php /commercial/

Result in the browser

http://www.terryliveseyphotography.co.uk/commercial/?mod_rewrite=on&page=galleries.php

hmmmm

Offline

#9 2017-04-22 01:44:08

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 623
Website

Re: .htaccess redirect not working

Or maybe

RewriteRule /galleries.php /commercial/ [R=301,L]

I would add this as the first rule after 'RewriteEngine On'


Daniel Leu | Photography   
DanielLeu.com

Just a user who loves to dive into techie stuff... and sometimes gets into trouble for that.

Offline

#10 2017-04-22 02:25:40

Terry
Member
From: United Kingdom
Registered: 2013-02-19
Posts: 66
Website

Re: .htaccess redirect not working

Just did that with the same result. hmm

The other lines which are in sub directories work fine but looking at Matt and Bens bits in there it looks like they are watching what happens at the root.  I'm sure there will be a way to format it but not found it, maybe I need to format the to address differently.

Thanks for your help though smile

Offline

#11 Yesterday 19:28:17

Terry
Member
From: United Kingdom
Registered: 2013-02-19
Posts: 66
Website

Re: .htaccess redirect not working

So I have deduced that anything in the root is redirected (or anything under the control of backlight) so I reverted to uploading a php file the name of the old link with the following code to do a permanent redirect:

<?php
// PHP permanent URL redirection
header("Location: http://www.terryliveseyphotography.co.uk/training/", true, 301);
exit();
?>

Just need to work on redirecting the directories but put this up there for anyone else wanting to do the same.

Offline

Board footer

Powered by FluxBB