Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

htaccess page redirect

I want to redirect a page on my website using  a htaccess file. I want everything in the insight directory, no matter what type of page or folder contained in the folder to redirect.  I don not belive I have written my htaccess file correct.  This is what I have so far:

redirect http://www.MYSIGHT.com/insight/ http://dev.MYSITE.com/index.php/practice/listings/

Open in new window

Avatar of nap0leon
nap0leon

Try placing this htaccess file in the insight directory.
You'll want to change the value of "NewLocationHere"

Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^insight(.*)$ http://www.MYSIGHT.com/NewLocationHere$1 [L,R=301]

</IfModule>

Open in new window

Avatar of Robert Granlund

ASKER

That works ok, but not all the way.

if I type in www.MYSITE,com/insight/index.php
the redirect should send it to:
 http://dev.MYSITE.com/index.php/practice/listings/
but right now it sends it to:
 http://dev.MYSITE.com/index.php/practice/listings/index.php/

In the new folder there is NOT an index.php, I have an index.html
It also adds a backslash to the very end that I don't won't.

This is what I have so far:

RewriteRule ^insight(.*)$ http://www.MYSITE.com/index.php/practice_career/od-listings

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of nap0leon
nap0leon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Looks like the only real difference between what you have and my code is that I included "[L,R=301]" at the end which tells the browser that it is a 301 redirect.

Please post a couple examples of what does and does not work with your current rule so I can get a feel for what might be missing...

e.g.,
subdirectory redirects:  /insight/folder1/page.php redirecting to "..."
page redirects:  /insight/index.php redirecting to "..."
and any others that may not be working right
It is re-directing the folder fine, but it is holding onto everything after the folder redirect and tacking it on to the end of the new url.
It is including the page and subfolder names even after removing the $1 from the redirect?
yes it is.