Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect in apache?

This should be a simple issue but I can't figure this out. I have a webpage running on a machine to access from the local network. I want to redirect the results of scripts run under cgi back to my /var/www/index.html/ file. I tried to place a redirect line in my /etc/apache2/apache2.conf`` that didn't work so I tried an even simpler task:

redirect permanent /var/www/index.html http://www.google.com

And not even this worked.

What am I doing wrong?

I'm running this on an Ubuntu machine.

Edit:

This is added to my error log when I restart the server:

[Sat Jun 16 17:26:36 2012] [notice] caught SIGTERM, shutting down         | * Restarting web server apache2
[Sat Jun 16 17:26:36 2012] [notice] Apache/2.2.22 (Ubuntu) configured -- \|apache2: Could not reliably determine the server's fully qualified domain \
resuming normal operations      

Edit: Solved and a new problem

I have managed to redirect the webpage to google and now I want to do the actual redirect. I have added this to my apache2.conf file

Redirect permanent /cgi-bin/file.cgi /index.html

And removed the previous file. The file now is redirected to google and not back to my home file...

What's going on?

like image 260
Yotam Avatar asked Oct 25 '25 01:10

Yotam


1 Answers

As far as I know the redirect is not based on a 'file' but on an URL.

So in your case you should try:

Redirect permanent /index.html http://www.google.com

See the apache docs for more information: http://httpd.apache.org/docs/2.0/mod/mod_alias.html#Redirect

You could also try mod_rewrite, but keep in mind it works on incoming requests/URLs not on files on the filesystem.

ps. Make sure you reload you configuration after your changes.

like image 57
Jeroen Avatar answered Oct 27 '25 00:10

Jeroen