Forum Moderators: phranque
This is the page I want to redirect:
http://www.example.com/articles/Main-Page
to
http://www.example.com/
I first redirected using this code:
RedirectMatch permanent ^/$ http://www.example.com/articles/Main-Page
Now, how can I convert this to http://www.example.com/?
Not sure I understand what the goal is?
Are you trying to direct people to the inner directory and then back to the main index? If so, why not just remove the first redirect?
Are you trying to serve the information from index.php at the inner directory?
Please, clarify what you are trying to accomplish.
Justin
I have:
RewriteBase /
RewriteRule ^random-page/somethin/$ [somedomain.com...] [R=301,L]
And it works just fine...
RedirectMatch permanent ^/$ http://www.example.com/articles/Main-Page
RewriteRule ^articles/Main-Page$ http://www.example.com/ [R=301,L]
Is an infinite loop... user accesses example.com - then they are redirected to /articles/Main-Page - then they are then redirected to example.com - then they are redirected to /articles/Main-Page - then they are redirected to example.com, over and over and over until the server hits the max redirect limit and spits out a 500 internal server error.
Justin
So http://www.example.com/articles/Main-Page should really look like http://www.example.com/
Hope that clarifies it.
I tried this:
DirectoryIndex /articles/Main-Page
And it worked but only problem is http://www.example.com/any-folder/ also redirects to /articles/Main-Page
Very weird
RewriteRule ^$ http://www.example.com/articles/Main-Page [R=301,L]
Will redirect requests for your home page to http://www.example.com/articles/Main-Page, and it will change the URL in the browser as well.
You may want to add:
RewriteRule ^index.html$ http://www.example.com/articles/Main-Page [R=301,L]
For anyone who may be linking to that page...
@jd01:
I meant to only use the one, not both.
RewriteRule ^(index\.html)?$ http://www.example.com/articles/Main-Page [R=301,L]
\. = escaping the .(dot) compares a litteral .(dot), not 'any character except the end of a line)
() = grouping
? = 0 or 1 of the preceding characters or gorup of characters.
So, this will rewrite both /index.html and / to /articles/Main-Page correctly.
Justin
Back to my first question - what exactly are you trying to do?
Are you trying to get the information from the deep location to the root level?
You will need to take out the Redirect and serve the information from the deep directory:
RewriteRule ^(index\.html)?$ /articles/Main-Page [L]
If you do not remove the first redirect:
RedirectMatch permanent ^/$ http://www.example.com/articles/Main-Page
You will have a conflict and people will not be able to access your home page, they will all be redirected to the inner page.
Justin