homepage Welcome to WebmasterWorld Guest from 54.242.126.9
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Problem getting mod-rewrite to work.
Brand new server setup
neiljones

10+ Year Member



 
Msg#: 3301 posted 6:32 pm on Apr 7, 2005 (gmt 0)

I am moving my sites to a new server.
I need to get mod-rewrite working.

I have the foloowing test .htaccess in a test directory

RewriteEngine on
RewriteRule ^old.html$ new.html

the only line mentioning the word requitre in the httpd.conf file is

LoadModule rewrite_module modules/mod_rewrite.so

I have also changed a line to

AllowOverride All
It was set to None

accessing the file old.html with the browser does not bring up new.html

What is wrong?

 

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3301 posted 8:10 pm on Apr 7, 2005 (gmt 0)

You may need to add the directive

Options +FollowSymLinks

to your .htaccess file.

Or add FollowSymLinks to the list of Options in httpd.conf.

Check your server error log -- It will tell you if this is the problem.

Jim

neiljones

10+ Year Member



 
Msg#: 3301 posted 9:09 pm on Apr 7, 2005 (gmt 0)

I have tried the options statement in the .htaccess
this is to no avail.

The error_log shows just
the message File Does not Exist:
an identical error message is appearing in the logs for pages in other as yet uncreated directories which were on the site bevore it was moved.

It is almost as if mod-rewrite is not switched on.

I am baffled.

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3301 posted 5:03 pm on Apr 8, 2005 (gmt 0)

In the error log, which file does it say does not exist -- old.html or new.html?

Also, it should give a full path to the file in that error line. Does the path look correct?

The requirements for mod_rewrite are:

Rewrite module loaded
AllowOverride directive specifying FileInfo and Options, or All
Options FollowSymLinks or SymLinksIfOwnerMatch enabled
Valid rewrite code in httpd.conf or .htaccess file

It seems you've satisfied all requirements, so I'm baffled, too.

If a directory is aliased, then control for that directory is 'diverted' before your web-root .htaccess file can have any effect. This often causes problems when people try to invoke rewrites intended to affect the cgi-bin directory, which is usually aliased for security reasons. You didn't mention cgi-bin, so this is not likely to be the problem, but I thought I should mention it.

Jim

neiljones

10+ Year Member



 
Msg#: 3301 posted 5:50 pm on Apr 8, 2005 (gmt 0)

Thanks Jim

In the error log it is old.html that does not exist
accessing new.html directly works.
the error path for old.html is the filepath of the actual file on the server which is correct.

The httpd.conf requirements you mention are what is set.

I am using
VirtualDocumentRoot
to host several domains on one ip.

I have made a chang to the .htaccess

RewriteEngine on
RewriteRule ^old\.html$ new.html

No effect

I am not ising cgi-bin the idea is to use a php program to handle things when I have all of this enabled

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3301 posted 2:31 am on Apr 9, 2005 (gmt 0)

Just to verify: You are placing this code in .htaccess, and not in httpd.conf?

Jim

neiljones

10+ Year Member



 
Msg#: 3301 posted 12:38 pm on Apr 9, 2005 (gmt 0)

It is in .htaccess

I have however made some progress. I have discovered how to solve the problem PARTIALLY.

My httpd.conf file is <apparently causing it not to> work.

If I comment out the line that starts VirtualDocumentRoot
and put the pages where the default DocumentRoot statement expects them to be, it works.

However I need this to work with name based virtual hosting.

[edited by: jdMorgan at 4:11 pm (utc) on April 9, 2005]
[edit reason] Removed specifics per TOS. [/edit]

neiljones

10+ Year Member



 
Msg#: 3301 posted 4:16 pm on Apr 9, 2005 (gmt 0)

Eureka!
After quite a bit more playing around this is the solution.

<VirtualHost *:80>
ServerAdmin postmaster@example.com
DocumentRoot /path/path/example.com/
ServerName example.com
ErrorLog /path/example.com-error_log
CustomLog /path/example.com-access_log common
RewriteLog /pathd_rewrite_log
RewriteLogLevel 9
<Directory "/path/example.com">

Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
</Directory>
Options Indexes FollowSymLinks ExecCGI Includes
</VirtualHost>

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3301 posted 4:17 pm on Apr 9, 2005 (gmt 0)

Ok, I just wanted to make sure, because the syntax varies slightly between httpd.conf and .htaccess, in that the URL seen by RewriteRule is "localized" to the directory where that Rule appears -- That is, the directory path above the current directory is stripped off, so a RewriteRule in /widgets/pages sees only /images/widget.gif if /widgets/pages/images/widget.gif is requested, whereas in httpd.conf, RewriteRule sees the entire /widgets/pages/images/widget.gif URL.

I'm not very good at server setup, so hopefully someone else will come along who can help you with that issue. In the meantime, you might want to try experimenting with the UseCanonical name setting, as that's the only other thing I can think of that might cause trouble here.

Jim

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3301 posted 5:08 pm on Apr 9, 2005 (gmt 0)

Cross-posted...

Glad you got it working! And now that it does work, change the RewriteLogLevel 9 to log level 0, because it'll fill up your log with an awful lot of data and really bog down your server at that '9' setting.

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved