I this has been address elsewhere them please send me the link.
Thanks
lucy24
10:32 pm on Dec 5, 2011 (gmt 0)
Well, yes, it's been addressed several thousand times in this Forum over the years. Search should bring them right up. And then you can look over the Forums Charter-- it's the teeny little link near the top of the page directly above the huge "Apache Web Server" header. This will explain about using example.com. Doubly important in this forum because we need to see what you typed. The Forums Library won't hurt, either. I should, ahem, read it myself one of these days.
Then come back and show some of the fixes you've tried and explain exactly what happens. "It doesn't work" is not exact enough. That covers the whole range from "Nothing happens at all" to "I end up in the Internet equivalent of the Lost Luggage department in Guam" to "My server crashes".
sgr2000
10:54 pm on Dec 5, 2011 (gmt 0)
example.com/folder1/folder2/page.htm or php or html to example.com/folder1/folder2/page/
I had found something similar but could not modify it to work. I would do nothing or give me a server error.
What do you mean by "to" - an external redirect or an internal rewrite?
As for the index redirect, never use (.*) at the beginning of a pattern. See recent threads for more robust code.
The redirect code should also include the domain name in the redirect target.
sgr2000
2:09 am on Dec 6, 2011 (gmt 0)
this is a internal rediect. Can you link to the trheads for this particular situation or how do I need to word this in the search box to get the right threads
lucy24
2:23 am on Dec 6, 2011 (gmt 0)
There's no such thing as an internal redirect.
Redirect: Browser's address bar changes. User is sent to a new location. Doesn't matter if it's the same domain-- even the same sub-sub-subdirectory-- or a different one; either way they have to go "out there" and start over again as if they had never set foot on the site. (Apache's memory is even shorter than yours and mine. Whee!)
Rewrite: Browser's address bar does not change. User is secretly sent to a different location-- usually but not always in the same domain-- but they don't know it. And neither does their browser. And neither do the site logs. A type of rewrite everyone has met is the 404 error page. Your browser's address bar shows the page you thought you were going to. Your browser screen shows the content of the 404 page.
It sounds as if what you want is a redirect followed by a rewrite. But you gotta ditch that trailing / That's for directories-- that is, for their index files, whether named or auto-generated. The extensionless URL, if that's what you are aiming for, has absolutely nothing at the end.
g1smd
8:52 am on Dec 6, 2011 (gmt 0)
The Apache documentation sometimes refers to an internal redirect when what they mean is an internal rewrite.
lucy24
12:44 pm on Dec 6, 2011 (gmt 0)
With friends like these... ;)
sgr2000
1:19 pm on Dec 6, 2011 (gmt 0)
ok, let me be more specific. I am not a coder and know just the very basics of htaccess.
I have and old site with files that i moved to a wordpress cms. I can redirect the old site to the new site like these
example.com/folder1/folder2/oldpage.htm to example.com/folder1/folder2/newpage/
the problem i am having is links from other sites are going to example.com/folder1/folder2/newpage.htm instead of example.com/folder1/folder2/newpage/
i need a redirect that if a link goes to /newpage.htm it redirects to newpage/
If there is a thread that addresses this particular type of redirect then please send me or post the link. I have not been able to locate a solution to this particular
lucy24
11:37 pm on Dec 6, 2011 (gmt 0)
Search for these three terms together:
rewrite redirect THE_REQUEST
You will see that THE_REQUEST is the crucial part. Your question then boils down to a very common one: how to redirect to an extensionless url, and then rewrite to the location that serves the content, without going into an infinite loop.
g1smd
1:30 am on Dec 7, 2011 (gmt 0)
Use a RewriteRule with the [R=310,L] flags.
You'll need a RegEx pattern like this ^(([^/]+/)*[^/.]+)\.html?$
You'll use http://www.example.com/$1/ as the rule target.