Koozali.org: home of the SME Server

smeserver apache rewrite / redirection

Offline loejf

  • ***
  • 74
  • +0/-0
smeserver apache rewrite / redirection
« on: March 07, 2008, 06:04:29 PM »
Hi.
I´m trying to make at automatic redirection of all request on my server to a specific url, using rewrite rules.
But without any luck.
Can anyone point to a howto for this.
Best regards Loejf.
...

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: smeserver apache rewrite / redirection
« Reply #1 on: March 07, 2008, 07:10:05 PM »
Hi.
I´m trying to make at automatic redirection of all request on my server to a specific url, using rewrite rules.
But without any luck.
Can anyone point to a howto for this.
Best regards Loejf.
Making such a catch-all rule is dangerous as you might also loose access to your server-manager which could be a very hard penalty.

What have you done so far? What are the errors? A bit more information would be nice to help us try and help you. Perhaps you can also state why you want to do such a thing as there are a lot of experts in the forums that most of the times have creative (and simple) solutions for problems you might not have thought of other than overwriting default server-functionality.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline loejf

  • ***
  • 74
  • +0/-0
Re: smeserver apache rewrite / redirection
« Reply #2 on: March 08, 2008, 06:03:28 PM »
Hi.
I have tried the .htaccess solutuion with the content:
Rewriterule.....
But as I understand, this is no longere an option in smeserver.

Then I tried to put in the rewrite rule in the httpd.conf file. Didn´t word.

What I want to redirect i the 404 page not found rule, I send all requests for not existing webpages to at specific .php file to be handled.

Best regards, Loejf.
...

Offline Curly

  • ***
  • 114
  • +0/-0
Re: smeserver apache rewrite / redirection
« Reply #3 on: March 08, 2008, 09:26:37 PM »
I use rewrite rules on SME 7.3, so it not impossible.

In httpd.conf you must have a line

LoadModule rewrite_module modules/mod_rewrite.so

in .htaccess:

RewriteEngine on
RewriteRule ^index.html index.php [L]


I'm not sure I have done anything special to get this working.
.......................................

Offline Normando

  • *
  • 841
  • +2/-1
    • Unixlan
Re: smeserver apache rewrite / redirection
« Reply #4 on: March 09, 2008, 06:59:37 AM »
loejf

Please, can you give a real example of what are you trying? Not how.

Offline loejf

  • ***
  • 74
  • +0/-0
Re: smeserver apache rewrite / redirection
« Reply #5 on: March 11, 2008, 12:32:00 PM »
Hi Normando.

I am trying to get the Apache server to use my own 40X webpages, instead of the default ex. 404 message.
Because I want to handle it.

Best regards Loejf.
...

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: smeserver apache rewrite / redirection
« Reply #6 on: March 11, 2008, 12:36:08 PM »
Hi Normando.

I am trying to get the Apache server to use my own 40X webpages, instead of the default ex. 404 message.
Because I want to handle it.

Best regards Loejf.
Perhaps this will be off help: http://www.devshed.com/c/a/Apache/Custom-Error-Pages-with-Apache/
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: smeserver apache rewrite / redirection
« Reply #7 on: March 11, 2008, 12:41:55 PM »
Perhaps this will be off help: http://www.devshed.com/c/a/Apache/Custom-Error-Pages-with-Apache/
I use this template to have internationalized error pages: http://www.snetram.nl/75InternationalizedErrorPages

You need a few files in the /var/www/error/ as templates, unfortunately I have no location for you to download them so quick. If I find the time I will try and share them to you for a while.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline loejf

  • ***
  • 74
  • +0/-0
Re: smeserver apache rewrite / redirection
« Reply #8 on: March 11, 2008, 03:24:00 PM »
Hi.

Writing this part directly in the httpd.conf

ErrorDocument 404 /404.htm

Works
...

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: smeserver apache rewrite / redirection
« Reply #9 on: March 11, 2008, 03:43:22 PM »
Hi.

Writing this part directly in the httpd.conf

ErrorDocument 404 /404.htm

Works

You can do so but to keep changes over updates and reconfiguration actions you will have to add a template fragment as you will loose your changes over configuration changes and upgrades this way. For more information on the template system see the SME Server Developers Guide linked from the wiki.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline loejf

  • ***
  • 74
  • +0/-0
Re: smeserver apache rewrite / redirection
« Reply #10 on: March 11, 2008, 09:17:23 PM »
Hi Cactus.

Thank you very much.
I´m aware of that.

Best regards Loejf.
...

Offline axessit

  • ****
  • 211
  • +0/-0
Re: smeserver apache rewrite / redirection
« Reply #11 on: September 23, 2010, 06:15:03 AM »
made a template fragment as follows

mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
cd /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf


vi or pico S85ErrorPages and add the following

# Add custom error pages here
ErrorDocument 404 /notfound.html


Exit from vi

Commit changes

expand-template /etc/httpd/conf/httpd.conf
/etc/init.d/httpd restart


with your favourite html edit, create a nice looking page at save in Primary/html ibay as notfound.html then open your browser and type in a bad URL (making sure the domain IS valid) eg http://myserver/dunno and your page should be displayed.

If you have virtual domains, you can create a custom errorpage and save in the html folder of the appropriate domain primary ibay.


Don't forget your other common error document pages such as
400 Bad Request
401 Unauthorized
403 Forbidden

These can be accommodated by appropriate lines in the template fragment ot point to your new wizbang pages.
A full list can be found at http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html