redirect by file extension in htaccess - .htaccess

I need to redirect all calls to aspx files in a specific sub-folder of the web to the same name and path with a .php extension.
For example
/onlinehelp/default.aspx will go to /onlinehelp/default.php
/onlinehelp/stuff/junk.aspx will go to /onlinehelp/stuff/junk.php
It seems simple enough, but I can't get it to work. I thought this would work:
RedirectMatch 301 (/onlinehelp/.*)\.aspx$ http://www.mydomanin.com$1.php
What am I missing?

thank you...it is working ....now. must have been a caching problem. curse the load balancers!!! lol sorry for the trouble. I appreciate the responses
The .htaccess file is sitting in the subfolder /onlinhelp/ where I need the redirection to take place.

Related

Setup htaccess not to redirect when hit from main site

I'm not even sure how to ask this correctly so if I am duplicating a question I apologize. How do I use my htaccess file to only redirect when someone is coming in on something other than the main site name?
Example:
I do not want redirect on www.examplesite.com
I do want to redirect on www.examplesite.com/page.php
I think this is what you're looking for:
Perform a redirection with .htaccess
The easiest and simplest way of redirecting with .htaccess is to use the Apache module mod_alias and its command Redirect. Here’s is how to make a temporary redirection with htaccess:
Redirect /page.php http://www.examplesite.com/go_to_this_page.php
Is this along the lines of what you're asking? If so, I hope it can help.
The Structure : redirect accessed-file URL-to-go-to
The code :
Redirect 301 / http://www.examplesite.com/page.php

301 redirect using regular expression in .htaccess

I have suddenly been hit with hundreds of 404 crawl errors to pages which must have been on a previous site (though I thought I'd got them all...). It's a bit strange as I've never seen any page with index.php in it, yet all the errors start with index.php/xxxxx.
So, I want to do the following:
redirect 301 index.php/<wildcard> http://www.example.com
in the .htaccess file.
Can someone tell me whether this is correct, and what I have to put in the <wildcard> place if it is? If this is incorrect, what is the code to accomplish this?
You can use a the Redirect directive in the htaccess file and do a simple regular expression assuming your site doesn't use /index.php/query/parameters like some PHP frameworks do.
Redirect 301 /index.php/(.+) http://www.mysite.com

I deleted .htaccess but its effetcts remain

I'm getting started with making few redirect with .htaccess but I just made something wrong.
I was trying to make a redirect where when I write http://www.mydomain.com/it/about the browser jump to http://www.mydomain.com/it/about.php but I wrote something wrong!
I can't remember exacly what I wrote (I took some code over the Internet several times) but the problem now is that I've deleted the .htaccess but when I try to access to http://www.mydomain.com/it/about.php the browser is redirected to http://www.mydomain.com/it/about.
How can this happen???? There is not any .htaccess into the server!!!!!!
If you use a 301-Redirect ([R=301]), the Browser will cache the redirect. Try an other browser or delete your cache
Are you sure it's gone? .htaccess files are hidden for security.
Try uploading an empty .htaccess file.
disable the rewrite module by typing "a2dismod rewrite" in terminal and re enable it. this will remove effects of .htaccess file.

How can I use .htaccess to redirect a folder on my website to a folder on another website?

I'm trying to have everything in this folder on my website - http://www.mywebsite.com/media/images/* redirect to another website with the same structure i.e. http://www.theotherwebsite.com/XXX/media/images/* using .htaccess
Even simpler, it can be accomplished by Redirect alone, no need to use Rewrite.
Redirect permanent /media/images http://foobar.com/new/location
Okay... managed to figure this one out...
RewriteRule ^media/images/(.*)$ http://www.theotherwbsite.com/XXX/media/images/$1 [L]

.htaccess Redirect Directive file to directory

I'm writing a .htaccess to support a couple moved files on a site. The concept is that /filename.htm is now at /filename/index.htm and I want links to it to read just /filename/. Here is what I have:
redirect permanent /filename.htm http://www.example.com/filename/
Will this work as expected? Thanks.
Yes, your code looks good, should do the trick.

Resources