I'm hoping to redirect visits to any page in an old directory to the index page of a new directory. In other words, redirect: http://www.domain.com/facts/*.* to http://www.domain.com/newfacts/ Is this possible? If so, how could I do it? Thank you. p.s. In my .htaccess I currently have: RedirectPermanent /facts/ http://www.domain.com/newfacts/ Code (markup): but this only redirects the index page.
Put the following in your .htaccess: RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.domain\.com$ RewriteRule ^facts/(.*)$ http://www.domain.com/newfacts/ [R=permanent,L] Code (markup): See the URL Rewriting Guide and the mod_rewrite Reference Guide for all your rewriting needs!
Looked at that page and didn't understand anything, so I might as well jump in with my own question how would you redirect www.domain.com to www.domain.com/forums?
mod_rewrite is a bit overkill for this example, the following directive should do it in a simpler way... RedirectPermanent / /forums Code (markup):
RedirectPermanent *will* do just that. Don't use mod-rewrite unless you have to - it's slower than using plain redirect. PM me the URL and I will tell you what's wrong with the response. J.D.
I was intrigued by this and checked the docs: it indeed seems that, for instance, a directive "Redirect /facts http://domain.com/newfacts" will work so that if the client requests http://domain.com/facts/foo.txt, it'll be told to access http://domain.com/newfacts/foo.txt instead. However, I believe the original poster wanted a redirect to, essentially, http://domain.com/newfacts/ for all the original URLs. The RedirectMatch directive might provide functionality equivalent to my earlier mod_rewrite example, though. OTOH, the docs aren't clear whether it supports permanent (301) redirections, which the mod_rewrite will accomplish.
I have a question too after reading and trying to apply a redirect in .htaccess How do I redirect all incoming requests for domain.ro/whatever.... (domain.ro/whatever.fileextension or domain.ro/whatever/whatsoever.html) to domain.ro ? So basically all url requests should point to domain.ro
I managed to do it For anyone who comes here and wants to know, too, here it is: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L] RewriteRule \/.+ / [L,R] Code (markup):
Hello, I thought this might be helpful for some people. I needed to redirect the contents of a complete folder to our main site. And here is how I achieved this: redirectMatch 301 ^/drupal/ http://www.itmontreal.ca Best regards, http://www.itmontreal.ca
and i needed the whole domain, so i just removed the folder name and trailing slash. this redirects all urls in the old domain to the home page of the new site. not the best for seo but no time. redirectMatch 301 ^/ http://www.vermont-web-design.com
Hi, I need to redirect all users either to the main domain or any .htm files inside that domain to a new domain's homepage. The redirectMatch 301 rule works just fine for this. But, there's a folder called 'FTP' inside the public_html directory. I want users to still be able to access this folder but other URL requests should be redirected. How do I achieve this? Any help would be greatly appreciated. Thanks, Sudarshan
open your FTP directory index.php file and put this code to redirect another location. <?php Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://www.new-url.com" ); ?>
I was stuck on this exact same problem. Most solutions work, but not perfectly. I wanted it to work with all files on the domain, even ones that don't exist, and to not transfer the filename to the new location. Here is my code: ErrorDocument 404 /404.php RedirectMatch 301 ^/$ http://www.danspoker.com/rakeback.html In 404.php: <? Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://www.danspoker.com/rakeback.html" ); ?>
can you please help me on this redirect problem installed forum software in forums directory and linked subdomian to it working very well but when user type domain.com/forums/ it will not redirect to subdomain how can i fix that http://asf-mobiles.com
Thanks Dan277 . I was looking for this one for a while.Great to be able to redirect 404 pages to any page I like and not only to the home page.