• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 496
  • Last Modified:

Apache redirect

Hello,
 I would like to use apache to redirect pages to a new path.

E.g 1
OLD URL  =http://server1/mwiki/devwiki/index.php/page1.php
Redirect = http://server2/publicwiki/index.php/page1.php

E.g 2
OLD URL  =http://server1/mwiki/index.php/page3.php
Redirect = http://server2/privatewiki/index.php/page3.php

Thanks for the help
0
SiemensSEN
Asked:
SiemensSEN
2 Solutions
 
a1jCommented:
On server1 in apache config or .htaccess

RewriteBase /
RewriteRule ^mwiki/devwiki/index.php/page([0-9]*).php http://server2/publicwiki/index.php/page$1.php [R=301,L]
0
 
vabelloCommented:
Hello,

You can use the Redirect directive in your Apache configuration. For example on server1 use:

Redirect /mwiki/devwiki/index.php/page1.php http://server2/publicwiki/index.php/page1.php

Redirect /mwiki/index.php/page3.php http://server2.privatewiki/index.php/page3.php

You may not want to redirect just a specific file like that but rather the whole directory. If this is the case, just omit the file names. The redirect will take the additional information in the original URL and append it to the final URL automatically.

Also, if you want it to be a permanent redirect (http response 301), put the word permanent between the Redirect directive and the original url. The defaults is a temporary redirect (http response 302).

You can use this in the main httpd.conf, virtual host context, directory context, or .htaccess file. This also requires mod_alias to be loaded and I'm assuming you're on Apache 2.2. For additional information, see the Apache documentation:

http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirect

There are other ways of doing redirects also. This may or may not be the best solution for you depending on what you are trying to achieve. Just for basic redirection it should fit the bill.

Hope this helps!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now