.htaccess Redirect Directive file to directory - .htaccess

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.

Related

redirect by file extension in 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.

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

Redirect custom URLs via htaccess

I have my own domain:
http://cesarferreira.com
and I wanna make
http://cesarferreira.com/github
point to
https://github.com/cesarferreira
Without having to make a /github/ folder with an index.html with a redirect for each page I own (facebook, twitter, pinterest, etc)
Is there a way like for example htaccess catchig *.com/github and pointing to a given static url?
Thanks a lot
If your document root serves -
http://cesarferreira.com
you can put a redirect in .htaccess like -
Redirect /github https://github.com/cesarferreira
Take a look at URL rewriter 'http://httpd.apache.org/docs/2.0/misc/rewriteguide.html'. That should be able to do everything you want and more.
As long as it is enabled in apache then you can use it in .htaccess files also.
You can use mod_alias:
Redirect 301 /github https://github.com/cesarferreira
Or if you only want github to point only to the folder:
RedirectMatch 301 ^/github https://github.com/cesarferreira
You can put that in the htaccess file of your document root.

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.

.htaccess to redirect all domain URLs

I would like to redirect example.com and example.com/ALL aswell as example.com/ALL/ALL, example.com/ALL/ALL/ALL etc. to example.com/offline.html, temporary. How can I do this through .htaccess ?
ALL = whatever you type
Thank you.
Redirect 302 / http://example.com/offline.html
Don't use .htaccess for this.
http://httpd.apache.org/docs/1.3/howto/htaccess.html#when
I'd recommend a proxy server.
Shovels for digging, hoes for sowing.
you just need create an HTML file called App_offline.htm then copy this file to the root of your web application
for more details have a look at:
http://msdn.microsoft.com/en-us/library/f735abw9(VS.85).aspx

Resources