logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: mod_rewrite not playing ball.
Author
stunfn



Joined: 16 Mar 2007
Posts: 3

PostPosted: Fri 16 Mar '07 20:12    Post subject: mod_rewrite not playing ball. Reply with quote

i'm trying to get a site working which came off a linux box and works with mod_rewrite. Now the site functionality works the same apart from the re-written urls.

the sites root is as follows http://localhost/ccc/ i'm doing some development work on it you see and i need mod_rewrite in order to complete the work and test it.

The rewrite module is loaded and i've set my httpd.conf to AllowOverride All so it will work.

The rewrite rules are in a .htaccess are as follows


Code:

RewriteEngine On
RewriteBase /

RewriteRule ^home/?$                /home.php          [QSA]
RewriteRule ^apply-here/([1-5]+)/([a-zA-Z0-9]{32})/?$   /apply$1.php?PHPSESSID=$2   [QSA]
RewriteRule ^apply-here/?$             /apply1.php          [QSA]
RewriteRule ^how-it-works/?$             /howitworks.php       [QSA]
RewriteRule ^about-us/?$             /aboutus.php          [QSA]
RewriteRule ^contact-us/?$             /contact.php          [QSA]
RewriteRule ^privacy-policy/?$             /privacy.php          [QSA]
RewriteRule ^terms-and-conditions/?$          /tandc.php          [QSA]
RewriteRule ^content/?$             /content.php          [QSA]


Now the problem is I can't work out why its not working. It works fine on the linux server I think its something to do with the rewritebase but I don't know what I know it gives me a 404 when i try to goto another page. I've tried setting RewriteBase / to RewriteBase /ccc/ but that still doesn't work. Any ideas anyone?
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Fri 16 Mar '07 22:00    Post subject: Reply with quote

The best way to figure out mod_rewrite problems like this is to set RewriteLogLevel,
i.e.
    RewriteLogLevel 9
and then check logs\error.log to see what matched or didn't match.

If you have one that doesn't behave as you expect, please post the RewriteRule and the log lines for executing that rule.

-tom-
Back to top
stunfn



Joined: 16 Mar 2007
Posts: 3

PostPosted: Fri 16 Mar '07 22:44    Post subject: Reply with quote

tdonovan wrote:
The best way to figure out mod_rewrite problems like this is to set RewriteLogLevel,
i.e.
    RewriteLogLevel 9
and then check logs\error.log to see what matched or didn't match.

If you have one that doesn't behave as you expect, please post the RewriteRule and the log lines for executing that rule.

-tom-


Ok i've added

RewriteLog "c:/Program Files/Apache Software Foundation/Apache2.2/logs/rewritelog.txt"
RewriteLogLevel 9

to my apache config in the <directory> section where the rest of the directives are but the apache server crashes

So how do I setup logging rewrite? apache just spits it dummy and refuses to start the service.
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Sat 17 Mar '07 5:21    Post subject: Reply with quote

re: "to my apache config in the <directory> section "

Both RewriteLog and RewriteLogLevel can only be used at the server or virtual-host level.
They must be set outside any <Directory> or <Location> blocks.

Apache should show you an error like:
    Syntax error on line NNN of c:/Program Files/Apache Software Foundation/Apache2.2/conf/httpd.conf:
    RewriteLog not allowed here
if you start Apache from the command line with these directives in the wrong place.

-tom-
Back to top
stunfn



Joined: 16 Mar 2007
Posts: 3

PostPosted: Sat 17 Mar '07 13:15    Post subject: Reply with quote

tdonovan wrote:
re: "to my apache config in the <directory> section "

Both RewriteLog and RewriteLogLevel can only be used at the server or virtual-host level.
They must be set outside any <Directory> or <Location> blocks.

Apache should show you an error like:
    Syntax error on line NNN of c:/Program Files/Apache Software Foundation/Apache2.2/conf/httpd.conf:
    RewriteLog not allowed here
if you start Apache from the command line with these directives in the wrong place.

-tom-


Ah ha righto well i'm not using vhosts at all, i'll set some up then and see if that sorts the issues out.

No I don't normally start/stop from the console I use the little apache applet for convenience.
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Sat 17 Mar '07 13:55    Post subject: Reply with quote

You don't need to set up any vhosts for this

- just make sure that both RewriteLog and RewriteLogLevel are outside any <Directory> blocks.

-tom
Back to top


Reply to topic   Topic: mod_rewrite not playing ball. View previous topic :: View next topic
Post new topic   Forum Index -> Apache