Apache redirect fool .aspx - linux

I have an apache server running in Linux and I'm wondering how I would go about redirecting urls? I want to do this via apache not by adding a header or redirect into the individual files. The goal is to get around having to deal with .aspx
Example1:
VISITING: wwww.myserver.com/file1.aspx
Will take you to: www/myserver.com/file2.php
Example2:
VISITING: www.myserver.com/file1.aspx?command1=set&command2=set
Will take you to: www.myserver.com/file2.php?command1=set&command2=set

Without using mod_rewrite, you can simply use mod_alias, in your vhost/server config or in an htaccess file:
Redirect 301 /file1.aspx /file2.php

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

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.

Need redirect old url to new friendly url

a need redirect
http://www.mysite.com/product.php?id_product=216
to
http://www.mysite.com/category/newProduct.html
I try to add a line in htacces
redirect 301 /product.php?id_product=216 http://www.mysite.com/category/newProduct.html
but dont work.
If I add
Redirect /product.php http://www.mysite.com/category/newProduct.html
All links like
http://www.mysite.com/product.php
http://www.mysite.com/product.php?id_product=216
http://www.mysite.com/product.php?id_product=219
Go to homepage http://www.mysite.com/
Any idea. THX
Check the following:
Make sure your file is called .htaccess, not htaccess as you say above.
If you're using FTP to transfer it to the server, use ASCII rather than binary transfer mode.
Make sure the .htaccess file is in a directory where the Apache AllowOverride directory option is on if you're using apache web server.

Redirect links to correct directory

We have on our site hundreds of links that point to:
/about/about/filename.html
But we need them to go to:
/about/filename.html
Is there a way to point them to the correct directory?
We are running on a Linux server and the site is build with Joomla Version 1.5.10 and there is ARTIO JoomSEF 3.8.2 running on it.
Thanks
Assuming you're using the Apache webserver, you can use mod_rewrite, specifically the RewriteRule directive:
RewriteRule /about/about/(.+)$ /about/$1 [R=301]
Place this rule in your httpd.conf file in the <VirtualHost> context for the site in question, or in a .htaccess file in the site's DocumentRoot.
This rule will create a 301 Permanent redirect for requests to any path under /about/about/ to the same path under /about/. e.g., /about/about/filename.html will redirect to /about/filename.html

How to configure apache server for sending a 301 code in response

I want to to configure Apache for moved permanently response.
What ever idea I have about this is --
1) I need to add below line in httpaccess
Redirect 301 /e/301
Can I put this line any where in httpaccess file?
2) then I have to have a page (say it is redirect.html, ) put in
/var/www/html/project_name.
Which will be displayed on redirection(will show 301 code).
Now what I want is, if someone access the page example.html, it need to be redirected to redirect.html .
Where and what syntax I need to add or what changes need to be done in httpd or other different Apache files.
Please correct me if I am wrong in above two points.
Thanks alot.
Got a solution-
We can do it be using Redirection directory or by re-write engine in httpdaccess.conf
for doing this by re-write engine add below line in conf file
RewriteEngine On
for 302 code
RewriteRule /.* http://www.new_server.com/ [R]
for 301 - permanent redirecting the your side to another one
RewriteRule permanent /.* http://www.new_server.com/ [R]
for page
Redirect /old.html http://ww.new_server.com/new.html
Redirect permanent /old.html http://www.new_server.com/new.html

Resources