?
Solved

htaccess redirect

Posted on 2013-06-26
12
Medium Priority
?
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 29

Expert Comment

by:Jan Springer
ID: 39279225
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
ID: 39279325
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
ID: 39279353
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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 29

Expert Comment

by:Jan Springer
ID: 39279366
It should.  Do the logs provide any information?
0
 

Author Comment

by:Refael
ID: 39279389
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 29

Expert Comment

by:Jan Springer
ID: 39279433
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
 

Author Comment

by:Refael
ID: 39279462
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
ID: 39279478
this code i have found works. is it good?

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

Expert Comment

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

Author Comment

by:Refael
ID: 39279581
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 29

Accepted Solution

by:
Jan Springer earned 1500 total points
ID: 39279617
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
ID: 39279625
Yes it should catch everything with "directory2". Thank you!
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

770 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