Link to home
Start Free TrialLog in
Avatar of mnkshy
mnkshy

asked on

URL redirection : apache 2.2

Hi,

I am running a web portal over apache 2.2.

My html files are located at: D:\web\apache\htdocs\drupal-4.6.3, and I have been accessing my web portal using the URL:
http://mymachineIP/drupal-4.6.3.

I want to define a new URL, http://newweb/ipe, and have all requests to this URL be redirected to http://mymachineIP/drupal-4.6.3.

I followed the instructions here: http://httpd.apache.org/docs/1.3/misc/howto.html
Added the following lines to my httpd.conf:

Redirect /  http://newweb/ipe
RewriteEngine On
RewriteRule /.* http://newweb/ipe [R]

This didnt work for me, could someone help me out with this please.

Thanks,
Meenakshi.

Avatar of ravenpl
ravenpl
Flag of Poland image

The simplest thing is to rename D:\web\apache\htdocs\drupal-4.6.3 to D:\web\apache\htdocs\ipe
But if not, then (remove end comments, and if used in .htaccess first leading slash[^/] from RewriteRule has to be stripped)
RewriteEngine On
RewriteRule ^/$ http://newweb/ipe/ [L,R] //redirect externally via browser
RewriteRule ^/ipe/(.*)$ /drupal-4.6.3/$1 [L] //redirect internally
Avatar of mnkshy
mnkshy

ASKER

Hi,

Thanks for the response.
I tried the posted comment as a solution. The URL: http://newweb/ipe redirects me to http://www.newwebpick.com/, which is strange !!!!

I am not able to make use of the other simple option. Sorry for not putting the question more straight forward.

My server name is portal.ipe.vrsn.com. This is where the apache webserver runs. The htdocs is a level down:  portal.ipe.vrsn.com/drupal-4.6.3.

So whereas the URL: http://portal.ipe.vrsn.com/drupal-4.6.3 takes me to the correct location, I want to redircet all requests to http://portal.ipe.vrsn.com to http://portal.ipe.vrsn.com/drupal-4.6.3, without adding a /drupal-4.6.3 or /ipe (renaming drupal-4.6.3 to ipe) in the URL.

Currently Ive put a redirect html, which on being clicked, takes the user to http://portal.ipe.vrsn.com/drupal-4.6.3. All I am trying is to do that redirection internally, so that the URL does not change.

Thanks again.
Meenakshi.




ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mnkshy

ASKER

Hi,

I am afraid, I am messing up somewhere probably.
My doc root is /app/www/html.

1. I enabled htaccess first of all in httpd.conf,
<Directory "/app/www/html/">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

And commented out:
#DirectoryIndex index.html index.php

2. The .htaccess file reads:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^drupal-4.6.3
RewriteRule (.*) /drupal-4.6.3/$1 [L]

3. Restarted httpd service: /etc/rc.d/init.d/httpd -k restart

4. Accessing the URL: 'http://portal.ipe.vrsn.com'; yet the index.html is served (which was initially taking care of the redirection).

I dont get where I am goofing up. Thanks for looking at the small things again.

Meenakshi.
Avatar of mnkshy

ASKER

Hi,

I tried the solution again. No index.html is being served(that was some file placed in teh directory, which was showing the index html).

My htaccess file reads:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^drupal-4.6.3
RewriteRule (.*) /drupal-4.6.3/$1 [L]

I am accessing teh web portal using URL:
http://portal.ipe.vrsn.com  (doc root = /app/www/html).

The html content would be located at /app/www/html/drupal-4.6.3

However, the redirection does not seem to work fine and I keep getting the error:

"Not Found
The requested URL / was not found on this server."

Can you please have a look at this one.

Thanks lots,
Meenakshi.
Avatar of mnkshy

ASKER

Hi,

Clean solution and works perfectly fine.
My htaccess file reads:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^drupal-4.6.3
RewriteRule (.*) /drupal-4.6.3/$1 [L]

Another approach for the situation, if u edited your index.html as:
<HTML>
<script language="javascript">
document.location.href = "drupal-4.6.3/";
</script>
</HTML>
So when I access the web portal using URL : http:/portal.ipe/vrsn.com, it gets redirected to http://portal.ipe.vrsn.com/drupal-4.6.3.

Both the solutions work on my web site.

Thanks tons !!!!
Meenakshi.