Ravens PHP Scripts: Forums


View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Author Message
Site Admin

Joined: Aug 29, 2004
Posts: 9449
Location: Arizona

PostPosted: Fri Oct 14, 2005 9:16 pm Reply with quote

My appologies in advance for the seemingly double posting, but I felt that it was in a topic that didn't properly reflect the issue.

I am really at my wits end. I am trying to GT my site. I believe that all the edits are properly done, but I cannot get mod_rewrite to work on my development Apache instance, which, is obviously a requirement. My development instance is running on Windows 2000 (just a simple laptop). I have verified that .htaccess is being read and used (because of my allow/deny entries are working), however, no mod_rewrite.

I thought it was as easy as uncommenting the two directives in httpd.conf for LoadModule and AddModule, but when I do apache -l, mod_rewrite doesn't show up in the list.

So, two questions and a request for help:

1. Is there some other setting in httpd.conf that I am missing?

2. Does mod_rewrite.c have to be compiled INTO Apache? Since it was under the DSO directives of LoadModule, I was under the impression it would be dynamically loaded and I can see the .so file under the modules folder.

Now for the request for help. Is anyone willing to share with me a working httpd.conf file (censored of course), that is working on Apache 1.3.x on a windows machine? If so, I can PM you my email address if you do not wish to post something here and then If I get it working from that, I will document in this thread the key directives that need to be set to possibly help others out.

Very much appreciated!


P.S. I have also already tried uninstalling Apache and installing the latest 1.3.33, to no avail.

Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17077

PostPosted: Fri Oct 14, 2005 11:00 pm Reply with quote

That is strange. -l only lists the pre-compiled modules and there are several that won't be listed. Add this code to your httpd.conf after the last AddModule statement
<IfModule mod_rewrite.c>

   php_admin_value disable_functions 'montego'

Then run phpinfo() and find the disable_functions setting. If mod_rewrite.so is available, then you should see montego listed.
View user's profile Send private message
PostPosted: Sat Oct 15, 2005 6:55 am Reply with quote


As always, I learn new "tricks" when you post! Thanks!

It is stranger still. I DO see montego listed in the disable_functions row. So, on that "hunch", I removed the above directives back out of httpd.conf and instead put the following into my root .htaccess file:


<IfModule mod_rewrite.c>
   php_flag display_errors off

Just to be sure, I tried it several times with toggling between "off" and "on" and the right value showed up under the php_info() output line for "display_errors" in the local setting column.

Ok, so that confirms for me that mod_rewrite IS loaded and that the GT-NextGen tester tool may, in fact, not be working properly on my environment. However, it gives me a good clue to dig more into. I will report back here as to what I find and any more issues that I run into.


PostPosted: Sat Oct 15, 2005 7:40 am Reply with quote

Place this in .htaccess and see if you get the Forbidden screen
RewriteEngine On

RewriteRule ^.*$ - [F]

If you do, then mod_rewrite is working Smile
PostPosted: Sat Oct 15, 2005 10:22 am Reply with quote

This is why the Community at Large needs to help support, financially, ravenphpscipts.com! Raven, and other moderators and regulars, selflessly makes their combined years of experience available to anyone who comes along to his site with a question, issue, concern, etc. With Raven's small tips above, I was finally able to get mod_rewrite working on my Windows 2000 based development machine.


Now, to give back to the Community (as we ALL should)... It finally came down to what I believe to be two key issues:

1. I was trying to test using the mod_rewrite_test.php and provided .htaccess from Only registered users can see links on this board! Get registered or login! site, but it did not work in my case (turns out mod_rewrite WAS working all along -- Thanks Raven!). Although I am sure that it must work for some configurations, just be aware that for your specific environment it may not and you may want to try the suggestions from Raven above. (I'll explain what I did -- slightly different -- in a minute.)

2. My development version of nuke that I was working with was buried under the main apache document root and therefore the ^xxxxxxxx.html directives would definitely not be found. I configured Apache to use virtual hosts to bring my document root for the particular development instance I was working on back to the "/" level.

Ok, with that said, let me first explain the few directives that must be set right within Apache to enable mod_rewrite. Look for the following directives and try the provided settings (others may wish to weigh-in if I have opened up any security holes):


LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c

<Directory />
    Options FollowSymLinks
    AllowOverride All

AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All

The last two directives related to identifying .htaccess as your override file and locking Apache down to only using it, I believe, is default, but wanted to provide it here for completeness sake. The sum total of these directives should be all that is needed to properly enable mod_rewrite, but now we get into validating it as such.

Raven's first post provided a key hint to me that it was possible to use .htaccess PHP flags in combination with a script to call phpinfo() to really debug and ensure mod_rewrite is working. First, in case one is not familiar with how to look at the inner configuration of PHP, create a new file called info.php (make sure you aren't overwriting an existing file) with the following statements in it:



Next, here is what I placed in my .htaccess file:


<IfModule mod_rewrite.c>
     php_flag display_errors Off

Then, from your browser access the .php script you created above. Find the directive display_errors. In the column labelled "Local" you should see "Off". I toggled from Off to On and back again just to make sure I could see the value change in this column (I would remove this from your .htaccess file as soon as you have validated that at least mod_rewrite is loaded).

Next step was to do a very simple mod rewrite just to make sure that the engine is working from my .htaccess file. I created the following rule -- replacing what I had previously such that my .htaccess file now looked as follows:


RewriteEngine On
RewriteRule ^info.html info.php

Now, all I had to do was go again to my browse and try to access info.html. You should get the phpinfo() output as it should have re-written your URL to call info.php instead of trying to find the non-existent file info.html.

That was it! That finally proved to me that mod_rewrite was working properly, within my document root, now I had to figure out how to get it working in my actual nuke site sub-directory.

With a little trial and error, I came up with the following. In my windows hosts file I added the following to ensure I could use a simple single-level "domain" name for my "server":

Code:       montegoscripts

Basically, this instructs windows to just forward my simple montegoscripts "domain" to my localhost IP (where Apache is running). Within Apache's httpd.conf file towards the end, I have the following:


NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin Only registered users can see links on this board! Get registered or login!
    DocumentRoot xxxxx/montegoscripts/html
    ServerName montegoscripts
    ErrorLog xxxxx/logs/montegoscripts/error.log
    CustomLog xxxx/logs/montegoscripts/access.log common

Substitute your directory structures for your environment. Now, please remember, this is for a DEVELOPMENT environment that is completely segregated and unreachable from the Internet. So, if you are your own internet-facing web host, please make sure you know what you are doing because I have no idea if the above is acceptable practice or not. It just worked for me.

That is it folks. Hopefully someone will find this helpful.

Again, for Raven and Company, many thanks!


PostPosted: Sat Oct 15, 2005 10:55 am Reply with quote

This might also be of assistance Only registered users can see links on this board! Get registered or login! .
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
Forums ©