Printer Friendly Version
Email this thread to a friend
|
Featured Web Site Template |
|
Reflects user activity within the last 5 minutes
|
|
| Member |
Message |
cajuns
Joined: Apr 10, 2006
# Posts: 104
|
Posted: 2008-Jun-14 16:02
Hi
I am trying to do a 301 redirect using.htaccess, and I am having a problem.
I know how to redirect this type:
/folder/file.htm
But I need to redirect a page that is not in a folder like this:
/file.htm and it isn't working. Any suggestions?
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2008-Jun-14 19:21
If you are using Mod_Rewrite in .htaccess, then be aware that the leading slash is not seen by the rule.
Post your best-effort code, using example.com instead of the real domain.
|
 |
cajuns
Joined: Apr 10, 2006
# Posts: 104
|
Posted: 2008-Jun-14 22:12
Thanks for the quick reply. I had tried to post it with something like mysite.com instead of my own url but it still came out as a link. So, I edited my post to keep it from being a link. Let me see if I can do it this time!
I do have a mod rewrite, and it works when a file is in a folder, then the file name, but it will not work trying it with just the file name. Kind of hard to explain in writing.
I have tried it this way:
redirect 301 /example_example.htm http://example-example.htm
After reading your reply, I also tried it leaving off the beginning slash for example_example.htm , but it still doesn't work.
I'm sorry if I am not being clear, but I am explaining it as best as I can.
Thanks again!
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2008-Jun-14 22:20
I can't see what is the domain name and what is the path.
Post using example.com as that will never be owned. Use italics around parts to stop it becoming a link.
I never use Redirect from Mod_Alias, I use RewriteCond and RewriteRule from Mod_Rewrite.
|
 |
cajuns
Joined: Apr 10, 2006
# Posts: 104
|
Posted: 2008-Jun-14 22:27
Okay, let me try it again,I really am trying to post it without it being a link.
Trying this way:
redirect 301 /example_example.htm "http://www.example-example.htm"
And this way:
redirect 301 example_example.htm "http://www.example-example.htm"
Hope it worked right.
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2008-Jun-14 22:41
"http://www.example-example.htm" could never be a valid URL.
If you are using "http" you'll need the domain name in there.
|
 |
cajuns
Joined: Apr 10, 2006
# Posts: 104
|
Posted: 2008-Jun-14 22:46
Ooops! Sorry! Still didn't come out right. Everything else is correct but the last part. The last part should be:
"http://www.example.com/example-example.htm"
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2008-Jun-14 22:51
You are better off using ModRewrite (RewriteRule), not Mod_Alias (Redirect) for this.
You will have much better control over what is and is not redirected.
Are you trying to redirect one, several, many, or all URLs?
|
 |
cajuns
Joined: Apr 10, 2006
# Posts: 104
|
Posted: 2008-Jun-14 22:54
Would it be okay with you if I sent you a PM with the way I have the rewrite rule? I am using ModRewrite (RewriteRule) I'm not sure how to post it in here.
I have different ones that I am redirecting, that are in folders. This is one of the ones I want to redirect that is not in a folder, or directory.
[ Message was edited by: cajuns 06/14/2008 03:07 pm ]
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2008-Jun-14 23:48
If you do use Mod_Rewrite, then it is very important that all of your rules come from that one Module, and that you do not mix rules from another Module - such as using "redirect" from Mod_Alias for example.
If you mix the rules, you will not be able to guarantee the order in which they are processed. That would be a major problem.
|
 |
cajuns
Joined: Apr 10, 2006
# Posts: 104
|
Posted: 2008-Jun-15 00:11
Hi
I am not using redirect" from Mod_Alias as far as I know. Not quite sure what that means? Oh well, thanks for trying, I appecitate your time
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2008-Jun-15 01:43
Yes, "Redirect" comes from the Mod_Alias module.
Look. I'm trying to get you to more usefully describe the problem; what should be redirected and what should not.
Is this same domain, or cross-domain?
|
 |
cajuns
Joined: Apr 10, 2006
# Posts: 104
|
Posted: 2008-Jun-15 17:25
Okay, I'm sorry, but I am really trying to explain it as best as I can, I guess I just don't understand enough about it.
It is the same domain. I had an incorrect link structure, and was redirecting to make the links correct. For example, I had links pointing to folders like this: ""http://www.example.com/example/example.htm"" I read somewhere on here the proper way was:""http://www.example.com/example/"" so I was using redirect for that. Those work.
Here is an example:
redirect 301 /example/example.htm ""http://www.example.com/example/""
Now I have some files that are not in a folder, that I want to rename, and redirect to the renamed ones, for example:
redirect 301 /example_example.htm ""http://www.example.com/example-example.htm""
I have tried it with the backslash, and without it.
Anyway, thanks for your time, I'm sorry I can't explain it any better than that.
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2008-Jun-15 17:46
Drop using Redirect and start using RewriteRule.
You can then test the filename, and redirect for just that one.
Use ^ for the start anchor (and $ for the end anchor if needed).
So ^file.htm is a filename that begins with "file.htm" and (as long as your .htaccess file is in the root) is in the root.
If you use RewriteRule for one of your rules, you will need to use it for ALL of your rules, otherwise you will not be able to guarantee which order they are processed in.
|
 |
cajuns
Joined: Apr 10, 2006
# Posts: 104
|
Posted: 2008-Jun-15 17:59
Oh, okay, thanks I think I get it now! I really appreciate your time.
|
 |
You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
- You have not yet logged in, or registered properly as a member
- You are a member, but no longer have posting rights.
- This is a private forum, for which you do not have permissions.
If you are a recent member, it's possible that you simply have not yet confirmed your account. Please
check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions
contained within.
If you cannot find this message, click here to Re-Send it.
|
If you are still experiencing problem, please read the
Login Assistance
Article for some advice on what may be causing your login not to work properly.
|
Switch to Advanced Editor and ...
Create a New Topic
or Reply to this Thread
|
|