You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Kory Wheatley <ko...@gmail.com> on 2018/01/18 04:53:44 UTC

[users@httpd] Redirect only a specific index.php page to new location

When someone types to go to http://sftpinterface/deptblogs/  or a link I
need it to redirect to http://intranet/template_departments.cfm.  Which I
was able to accomplish in the index.php header content with

<?php
/* Redirect browser */
 header("Location: http://intranet/template_departments.cfm");

/* Make sure that code below does not get executed when we redirect. */
exit;
?>

But the problem is all pages underneath http://sftpinterface/deptblogs
redirect to  http://intranet/template_departments.cfm.  Like I don't want
http://sftpinterface/deptblogs/nursing to be redirected to
http://intranet/template_departments.cfm.  I want it to stay on that page
along with the others.  Only http://sftpinterface/deptblogs or
http://sftpinterface/deptblogs/index.php  needs to be redirect to
http://intranet/template_departments.cfm and not the sub directory sites
underneath /deptblogs.  What's the possible way of doing this.

Re: [users@httpd] Redirect only a specific index.php page to new location

Posted by Daniel <df...@gmail.com>.
Without having a clear picture of everything in your config context
wise is hard to tell.

So seeing as you are using .htaccess which adds complexity perhaps you
need to examine what's going one behind the scenes with rewrite
debugging:

See https://wiki.apache.org/httpd/RewriteLog

2018-01-27 1:49 GMT+01:00 Kory Wheatley <ko...@gmail.com>:
> Thanks for your response  Daniel... I tried your suggestion but it didn't
> seem to work RewriteRule ^/deptblogs/$
> http://intranet/template_departments.cfm [R,L]
>
> See below thank your for troubleshoot do I need to maybe put the
> redirectmatch in the httpd.con
>
> RewriteEngine On
> RewriteBase /deptblogs/
> RewriteRule ^/deptblogs/$  http://intranet/template_departments.cfm [R,L]
> RewriteRule ^index\.php$ - [L]
>
> # uploaded files
> RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2
> [L]
>
> # add a trailing slash to /wp-admin
> RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
>
> RewriteCond %{REQUEST_FILENAME} -f [OR]
> RewriteCond %{REQUEST_FILENAME} -d
> RewriteRule ^ - [L]
> RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
> RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
> RewriteRule . index.php [L]
>
>
> # increased maximum upload filesize from 2M to 50M
> # NOTE: In Internet Explorer, open Wordpress network settings also needs to
> be changed for the field 'max upload file size'=51200 KB
> php_value upload_max_filesize 50M
>
>
> On Thu, Jan 25, 2018 at 7:16 AM, Daniel <df...@gmail.com> wrote:
>>
>> I'm with Luca here.
>>
>> A simple redirectmatch would do what you seek.
>> RedirectMatch ^/deptblogs/$  http://intranet/template_departments.cfm
>>
>> Let PHP do complex stuff and let requests for simple paths be handled
>> with simple httpd directives, or at least, that's why I would do to
>> not lose hair in the process :)
>>
>> If you have an .htaccess in place like seems to be the case, then
>> perhaps this should be the first line after the RewriteBase:
>> RewriteRule ^/deptblogs/$  http://intranet/template_departments.cfm [R,L]
>>
>> This is the same as the redirectmatch but with a rewriterule and
>> defined the first to make sure it takes precedence over the
>> complicated directives later on.
>>
>> 2018-01-25 9:07 GMT+01:00 Marat Khalili <mk...@rqc.ru>:
>> > On 24/01/18 22:53, Kory Wheatley wrote:
>> >
>> > Ya there is a .htaccess that has the base set to deptblogs what could I
>> > change in here to get it to work?
>> >
>> > [kwheatley@sftpface2 wordpress]$ cat .htaccess
>> > RewriteEngine On
>> > RewriteBase /deptblogs/
>> > RewriteRule ^index\.php$ - [L]
>> >
>> > # uploaded files
>> > RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+)
>> > wp-includes/ms-files.php?file=$2
>> > [L]
>> >
>> > # add a trailing slash to /wp-admin
>> > RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
>> >
>> > RewriteCond %{REQUEST_FILENAME} -f [OR]
>> > RewriteCond %{REQUEST_FILENAME} -d
>> > RewriteRule ^ - [L]
>> > RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
>> > RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
>> > RewriteRule . index.php [L]
>> > #Redirect 301 / http://intranet/template_departments.cfm
>> >
>> >
>> > This looks too complex for me to interpret for sure without real-world
>> > tests, particularly, because [L] in .htaccess context does not actually
>> > end
>> > rewriting like one might though. (If you really want to be sure no
>> > redirect
>> > is already in progress, test REDIRECT_STATUS environment variable like
>> > this:
>> >
>> > RewriteCond %{ENV:REDIRECT_STATUS} ^$
>> >
>> > .)
>> >
>> > Looks like you have added some rules while trying to solve your problem,
>> > while rest came from default Wordpress installation. I'd leave only
>> > default
>> > Wordpress ones and see if it solves unnecessary redirects.
>> >
>> > --
>> >
>> > With Best Regards,
>> > Marat Khalili
>>
>>
>>
>> --
>> Daniel Ferradal
>> IT Specialist
>>
>> email         dferradal at gmail.com
>> linkedin     es.linkedin.com/in/danielferradal
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>



-- 
Daniel Ferradal
IT Specialist

email         dferradal at gmail.com
linkedin     es.linkedin.com/in/danielferradal

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Redirect only a specific index.php page to new location

Posted by Kory Wheatley <ko...@gmail.com>.
Thanks for your response  Daniel... I tried your suggestion but it didn't
seem to work RewriteRule ^/deptblogs/$  http://intranet/template_
departments.cfm [R,L]

See below thank your for troubleshoot do I need to maybe put the
redirectmatch in the httpd.con

RewriteEngine On
RewriteBase /deptblogs/
RewriteRule ^/deptblogs/$  http://intranet/template_departments.cfm [R,L]
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2
[L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]


# increased maximum upload filesize from 2M to 50M
# NOTE: In Internet Explorer, open Wordpress network settings also needs to
be changed for the field 'max upload file size'=51200 KB
php_value upload_max_filesize 50M


On Thu, Jan 25, 2018 at 7:16 AM, Daniel <df...@gmail.com> wrote:

> I'm with Luca here.
>
> A simple redirectmatch would do what you seek.
> RedirectMatch ^/deptblogs/$  http://intranet/template_departments.cfm
>
> Let PHP do complex stuff and let requests for simple paths be handled
> with simple httpd directives, or at least, that's why I would do to
> not lose hair in the process :)
>
> If you have an .htaccess in place like seems to be the case, then
> perhaps this should be the first line after the RewriteBase:
> RewriteRule ^/deptblogs/$  http://intranet/template_departments.cfm [R,L]
>
> This is the same as the redirectmatch but with a rewriterule and
> defined the first to make sure it takes precedence over the
> complicated directives later on.
>
> 2018-01-25 9:07 GMT+01:00 Marat Khalili <mk...@rqc.ru>:
> > On 24/01/18 22:53, Kory Wheatley wrote:
> >
> > Ya there is a .htaccess that has the base set to deptblogs what could I
> > change in here to get it to work?
> >
> > [kwheatley@sftpface2 wordpress]$ cat .htaccess
> > RewriteEngine On
> > RewriteBase /deptblogs/
> > RewriteRule ^index\.php$ - [L]
> >
> > # uploaded files
> > RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=
> $2
> > [L]
> >
> > # add a trailing slash to /wp-admin
> > RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
> >
> > RewriteCond %{REQUEST_FILENAME} -f [OR]
> > RewriteCond %{REQUEST_FILENAME} -d
> > RewriteRule ^ - [L]
> > RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
> > RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
> > RewriteRule . index.php [L]
> > #Redirect 301 / http://intranet/template_departments.cfm
> >
> >
> > This looks too complex for me to interpret for sure without real-world
> > tests, particularly, because [L] in .htaccess context does not actually
> end
> > rewriting like one might though. (If you really want to be sure no
> redirect
> > is already in progress, test REDIRECT_STATUS environment variable like
> this:
> >
> > RewriteCond %{ENV:REDIRECT_STATUS} ^$
> >
> > .)
> >
> > Looks like you have added some rules while trying to solve your problem,
> > while rest came from default Wordpress installation. I'd leave only
> default
> > Wordpress ones and see if it solves unnecessary redirects.
> >
> > --
> >
> > With Best Regards,
> > Marat Khalili
>
>
>
> --
> Daniel Ferradal
> IT Specialist
>
> email         dferradal at gmail.com
> linkedin     es.linkedin.com/in/danielferradal
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Redirect only a specific index.php page to new location

Posted by Daniel <df...@gmail.com>.
I'm with Luca here.

A simple redirectmatch would do what you seek.
RedirectMatch ^/deptblogs/$  http://intranet/template_departments.cfm

Let PHP do complex stuff and let requests for simple paths be handled
with simple httpd directives, or at least, that's why I would do to
not lose hair in the process :)

If you have an .htaccess in place like seems to be the case, then
perhaps this should be the first line after the RewriteBase:
RewriteRule ^/deptblogs/$  http://intranet/template_departments.cfm [R,L]

This is the same as the redirectmatch but with a rewriterule and
defined the first to make sure it takes precedence over the
complicated directives later on.

2018-01-25 9:07 GMT+01:00 Marat Khalili <mk...@rqc.ru>:
> On 24/01/18 22:53, Kory Wheatley wrote:
>
> Ya there is a .htaccess that has the base set to deptblogs what could I
> change in here to get it to work?
>
> [kwheatley@sftpface2 wordpress]$ cat .htaccess
> RewriteEngine On
> RewriteBase /deptblogs/
> RewriteRule ^index\.php$ - [L]
>
> # uploaded files
> RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2
> [L]
>
> # add a trailing slash to /wp-admin
> RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
>
> RewriteCond %{REQUEST_FILENAME} -f [OR]
> RewriteCond %{REQUEST_FILENAME} -d
> RewriteRule ^ - [L]
> RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
> RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
> RewriteRule . index.php [L]
> #Redirect 301 / http://intranet/template_departments.cfm
>
>
> This looks too complex for me to interpret for sure without real-world
> tests, particularly, because [L] in .htaccess context does not actually end
> rewriting like one might though. (If you really want to be sure no redirect
> is already in progress, test REDIRECT_STATUS environment variable like this:
>
> RewriteCond %{ENV:REDIRECT_STATUS} ^$
>
> .)
>
> Looks like you have added some rules while trying to solve your problem,
> while rest came from default Wordpress installation. I'd leave only default
> Wordpress ones and see if it solves unnecessary redirects.
>
> --
>
> With Best Regards,
> Marat Khalili



-- 
Daniel Ferradal
IT Specialist

email         dferradal at gmail.com
linkedin     es.linkedin.com/in/danielferradal

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Redirect only a specific index.php page to new location

Posted by Marat Khalili <mk...@rqc.ru>.
On 24/01/18 22:53, Kory Wheatley wrote:
> Ya there is a .htaccess that has the base set to deptblogs what could 
> I change in here to get it to work?
>
> [kwheatley@sftpface2 wordpress]$ cat .htaccess
> RewriteEngine On
> RewriteBase /deptblogs/
> RewriteRule ^index\.php$ - [L]
>
> # uploaded files
> RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) 
> wp-includes/ms-files.php?file=$2 [L]
>
> # add a trailing slash to /wp-admin
> RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
>
> RewriteCond %{REQUEST_FILENAME} -f [OR]
> RewriteCond %{REQUEST_FILENAME} -d
> RewriteRule ^ - [L]
> RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
> RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
> RewriteRule . index.php [L]
> #Redirect 301 / http://intranet/template_departments.cfm

This looks too complex for me to interpret for sure without real-world 
tests, particularly, because [L] in .htaccess context does not actually 
end rewriting 
<https://httpd.apache.org/docs/current/rewrite/flags.html#flag_l> like 
one might though. (If you really want to be sure no redirect is already 
in progress, test REDIRECT_STATUS environment variable like this:
> RewriteCond %{ENV:REDIRECT_STATUS} ^$
.)

Looks like you have added some rules while trying to solve your problem, 
while rest came from default Wordpress installation. I'd leave only 
default Wordpress ones and see if it solves unnecessary redirects.

--

With Best Regards,
Marat Khalili

Re: [users@httpd] Redirect only a specific index.php page to new location

Posted by Kory Wheatley <ko...@gmail.com>.
Ya there is a .htaccess that has the base set to deptblogs what could I
change in here to get it to work?

[kwheatley@sftpface2 wordpress]$ cat .htaccess
RewriteEngine On
RewriteBase /deptblogs/
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2
[L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
#Redirect 301 / http://intranet/template_departments.cfm


# increased maximum upload filesize from 2M to 50M
# NOTE: In Internet Explorer, open Wordpress network settings also needs to
be changed for the field 'max upload file size'=51200 KB
php_value upload_max_filesize 50M
php_value post_max_size 50M
php_value max_execution_time 500
php_value max_input_time 500
php_value memory_limit 128M


On Sun, Jan 21, 2018 at 2:31 AM, Marat Khalili <mk...@rqc.ru> wrote:

> On 18/01/18 07:53, Kory Wheatley wrote:
>
> When someone types to go to http://sftpinterface/deptblogs/  or a link I
> need it to redirect to http://intranet/template_departments.cfm.  Which I
> was able to accomplish in the index.php header content with
>
> <?php
> /* Redirect browser */
>  header("Location: http://intranet/template_departments.cfm");
>
> /* Make sure that code below does not get executed when we redirect. */
> exit;
> ?>
>
> It should work.
>
> But the problem is all pages underneath http://sftpinterface/deptblogs
> redirect to  http://intranet/template_departments.cfm.  [...]
>
> This shouldn't happen. Most likely there's another redirect rule
> somewhere, e.g. in .htaccess file.
>
> --
>
> With Best Regards,
> Marat Khalili
>

Re: [users@httpd] Redirect only a specific index.php page to new location

Posted by Marat Khalili <mk...@rqc.ru>.
On 18/01/18 07:53, Kory Wheatley wrote:
> When someone types to go to http://sftpinterface/deptblogs/  or a link 
> I need it to redirect to http://intranet/template_departments.cfm. 
> Which I was able to accomplish in the index.php header content with
>
> <?php
> /* Redirect browser */
>  header("Location: http://intranet/template_departments.cfm");
>
> /* Make sure that code below does not get executed when we redirect. */
> exit;
> ?>
It should work.

> But the problem is all pages underneath http://sftpinterface/deptblogs 
> redirect to http://intranet/template_departments.cfm. [...]
This shouldn't happen. Most likely there's another redirect rule 
somewhere, e.g. in .htaccess file.

--

With Best Regards,
Marat Khalili

Re: [users@httpd] Redirect only a specific index.php page to new location

Posted by Adam Powell <ad...@adaminfinitum.com>.
Have you read this document?
https://httpd.apache.org/docs/trunk/rewrite/avoid.html

-Adam Powell

> On Jan 19, 2018, at 3:33 AM, Luca Toscano <to...@gmail.com> wrote:
> 
> Hi Kory,
> 
> 2018-01-18 5:53 GMT+01:00 Kory Wheatley <ko...@gmail.com>:
>> When someone types to go to http://sftpinterface/deptblogs/  or a link I need it to redirect to http://intranet/template_departments.cfm.  Which I was able to accomplish in the index.php header content with
>> 
>> <?php
>> /* Redirect browser */
>>  header("Location: http://intranet/template_departments.cfm");
>> 
>> /* Make sure that code below does not get executed when we redirect. */
>> exit;
>> ?>
>> 
>> But the problem is all pages underneath http://sftpinterface/deptblogs  redirect to  http://intranet/template_departments.cfm.  Like I don't want http://sftpinterface/deptblogs/nursing to be redirected to http://intranet/template_departments.cfm.  I want it to stay on that page along with the others.  Only http://sftpinterface/deptblogs or http://sftpinterface/deptblogs/index.php  needs to be redirect to  http://intranet/template_departments.cfm and not the sub directory sites underneath /deptblogs.  What's the possible way of doing this.
>> 
> 
> have you checked https://httpd.apache.org/docs/current/mod/mod_alias.html#redirectmatch ?
> 
> Luca

Re: [users@httpd] Redirect only a specific index.php page to new location

Posted by Luca Toscano <to...@gmail.com>.
Hi Kory,

2018-01-18 5:53 GMT+01:00 Kory Wheatley <ko...@gmail.com>:

> When someone types to go to http://sftpinterface/deptblogs/  or a link I
> need it to redirect to http://intranet/template_departments.cfm.  Which I
> was able to accomplish in the index.php header content with
>
> <?php
> /* Redirect browser */
>  header("Location: http://intranet/template_departments.cfm");
>
> /* Make sure that code below does not get executed when we redirect. */
> exit;
> ?>
>
> But the problem is all pages underneath http://sftpinterface/deptblogs
> redirect to  http://intranet/template_departments.cfm.  Like I don't want
> http://sftpinterface/deptblogs/nursing to be redirected to
> http://intranet/template_departments.cfm.  I want it to stay on that page
> along with the others.  Only http://sftpinterface/deptblogs or
> http://sftpinterface/deptblogs/index.php  needs to be redirect to
> http://intranet/template_departments.cfm and not the sub directory sites
> underneath /deptblogs.  What's the possible way of doing this.
>
>
have you checked
https://httpd.apache.org/docs/current/mod/mod_alias.html#redirectmatch ?

Luca