Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite from apache 1.3 to apache 2.2 - all mod rewrite

exact working rewrite code on apache2.2 no longer works.

         

hans51

7:55 am on Oct 26, 2006 (gmt 0)

10+ Year Member



Hi all

2 days ago I had to move from shared hosting to dedicated server - my own boss now - also my own workhorse - too much traffic / CPU usage emailed me my host (1and1.com) ....

with previous apache 1.3 and php4.4 --- ALL worked perfectly!

now I have apache 2.2 and php5 and nothing at all work re rewriting

<snip>

about 70% of my pages are static HTML pages - rest dynamic PHP pges

before i had several mod_rewrite on my site - all in .htaccess - some simple some quite complex and all worked perfectly all times

with exactly same mod_rewrite syntax as before - on new server NO mod_rewrite works at all even the most simple.

I had / have from hotlink rewrite to domain.com ->> www.domain.com - and complex mod rewrite for my gallery2 photo gallery SW - all worked perfectly before

apache2 is new to me and it appears somehow that i have set at least ONE option or configuration too few ( ... or too much? )

in the apache global conf httpd.conf ( in my suse linux its default_server.conf )

I have the module mod_rewrite loaded - at least php-info says so
and i have enabled

Options MultiViews All ( where "All" should include all incl. option followsymlinks )

Options +FollowSymlinks

the most simple code i used before in .htaccess - NOW in the global conf - was

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$

http://www.example.com/$1
[L,R=301]

syntax test says:
> rcapache2 configtest
Syntax OK

any idea what to do to make mod_rewrite system wide working again?
any particular technique to migrate all working mod_rewrite code from apache 1.3 to apache 2.2?

help highly appreciated - i have spent the last 2+ days nearly day and night searching G and reading apache2 howtos and manuals with no success so far

[edited by: jdMorgan at 1:45 pm (utc) on Oct. 26, 2006]
[edit reason] Examplified, removed specifics per TOS. [/edit]

jdMorgan

1:52 pm on Oct 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The syntax is fine, but the pattern is not. If you move rules from config-level files such as conf.d to .htaccess or vice-versa, the URL-paths must be adjusted.

Your code may work better as


RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule [b]^/([/b].*)$ http://www.example.com/$1 [L,R=301]

or as

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.co[b]m$1[/b] [L,R=301]

Are you actually using MultiViews? If not, turn them off to prevent interference with mod_rewrite functions.

Also, remember that any changes you make to the server config files won’t take effect until after a server restart.

Jim