Solved

htaccess redirect

Posted on 2013-06-26
12
392 Views
Last Modified: 2013-06-26
Hello experts,

I am trying to do something very simple using htaccess:


Redirect all the page is following :

http://www.mydomain.com/direcotry1/directory2/

TO:

http://www.mydomain.com/direcotry1/301.html

There is already an htaccess file inside the "direcotry1" folder and its the only htaccess file i can access.

Thank you. I hope to find a quick resolution.
0
Comment
Question by:Refael
  • 7
  • 5
12 Comments
 
LVL 28

Expert Comment

by:Jan Springer
Comment Utility
Make sure that you have the rewrite engine on in your apache configuration and put this in the htaccess or section of the httpd.conf for this host:

RewriteCond %{HTTP_HOST}   !^www\.mydomain\.com/direcotry1/directory2/[NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://http://www.mydomain.com/direcotry1/301.html/$1 [L,R]
0
 

Author Comment

by:Refael
Comment Utility
Hi  _jesper_ thank you very much

In the htaccess i have already some few lines of code will pasting this harm anything else on that domain beside this directories?
0
 

Author Comment

by:Refael
Comment Utility
Hi again,

I have pasted your code yet nothing is happening.
I have more codes of RewriteRule for other sub-directories so maybe that's why it does not work?
0
 
LVL 28

Expert Comment

by:Jan Springer
Comment Utility
It should.  Do the logs provide any information?
0
 

Author Comment

by:Refael
Comment Utility
It should? what do you mean? it should work or the fact i am having more code there might create a problem?

i do not understand how does line 3 in your code knows that it should refer to line 1 in your code if i have more similar lines before it.
0
 
LVL 28

Expert Comment

by:Jan Springer
Comment Utility
Are you keeping the rewrite conditions with the rewrite rules that belong to them?  Are there any other rewrite rules that overlap with this?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:Refael
Comment Utility
still does not work...

i checked. there is no code related to this directory e.g. "directory2".
your rewrite rule have this " http://http://" is this ok?

would it be better to have an htaccess inside the "directory2" folder and then redirect all the pages from there?
0
 

Author Comment

by:Refael
Comment Utility
this code i have found works. is it good?

RewriteRule ^directory2/(.*) http://www.domain.com/directory1/301.html [R=301,L]
0
 
LVL 28

Expert Comment

by:Jan Springer
Comment Utility
No, it shoudn't have.  I apologize for the bad paste.  If corrected, does it work?
0
 

Author Comment

by:Refael
Comment Utility
Hi _jesper_

removing the double http did not help. but the code i found works fine, have a look above.
 
RewriteRule ^directory2/(.*) http://www.domain.com/directory1/301.html [R=301,L] 

Open in new window


is it ok to use just this code?
0
 
LVL 28

Accepted Solution

by:
Jan Springer earned 500 total points
Comment Utility
If it works, yes.  It will catch everything with "directory2" as a word of caution if you host multiple virtual hosts.
0
 

Author Comment

by:Refael
Comment Utility
Yes it should catch everything with "directory2". Thank you!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now