?
Solved

Apache MOD_REWRITE trouble

Posted on 2007-03-27
14
Medium Priority
?
178 Views
Last Modified: 2010-05-18
I am trying to set up mod_rewrite. in my httpd.conf file i have set it to load the mod_rewrite module, but when i try to set rewrite rules, it isn't working. here is my code:

RewriteEngine on
RewriteRule ^/error/([0-9]+)$ /error-pages/$1.php


I don't get errors, but when i go to "/error/404" to test it, it tells me the page isnt found and DOESNT show my custom error page.
0
Comment
Question by:Oscurochu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
14 Comments
 
LVL 27

Expert Comment

by:Nopius
ID: 18804339
If you are using rewrite engine in .htaccess, then tty these rules (in top htdocs directory .htaccess):

RewriteEngine On
RewriteBase /
RewriteRule ^error/([0-9]+)$ error-pages/$1.php

0
 
LVL 5

Author Comment

by:Oscurochu
ID: 18804357
im not doing this in htaccess, im doing it in httpd.conf

do i have to use .htaccess?
0
 
LVL 5

Author Comment

by:Oscurochu
ID: 18804376
i tried creating an .htacess file with the rewrite rules and it still isn't working
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:Nopius
ID: 18804506
For directory where .htacess resides please define AllowOverride option.

<Directory /...>
...
AllowOverride All
...
</Directory>

It works on my apache and I tested it before posting (but used 404.txt instead of 404.php).
It might be you placed your .htaccess into incorrect directory (not into the domain top /).
0
 
LVL 5

Author Comment

by:Oscurochu
ID: 18804609
i have "AllowOveride All" set
the .htaccess file IS in the top level directory
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18804678
Ok, let's start a debug session :-)

In 'httpd.conf' please define these directives:

RewriteLog /tmp/rewrite.log
RewriteLogLevel 3

When getting error look into /tmp/rewrite.log, access_log  and error_log and post here all related messages.
0
 
LVL 5

Author Comment

by:Oscurochu
ID: 18804791
its not giving me any errors, its just not working. rewrite.log is blank.

access_log:
70.127.251.232 - - [27/Mar/2007:20:56:23 -0400] "GET /error/404 HTTP/1.1" 404 -

error_log:

[Tue Mar 27 20:56:23 2007] [error] [client 70.127.251.232] File does not exist: C:/www/crackerblack.dyndns.org/public_html/error
[Tue Mar 27 20:56:23 2007] [error] [client 70.127.251.232] File does not exist: C:/www/crackerblack.dyndns.org/public_html/error
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18805242
If rewrite log is created by Apache then rewrite module is included.
If no logs there - your C:/www/crackerblack.dyndns.org/public_html/.htaccess is not picked up by apache and rewrite engine didn't turned on. Why - I dont' know. May be there are some Windows speific issues.

You said you did rewrite rules in httpd.conf. In what section did it (global/directory/virtual host)?
0
 
LVL 5

Author Comment

by:Oscurochu
ID: 18806681
i made an include file for convienence. i have the file included in httpd.conf, the file is included just fine though... i've done a few test to make sure the file is included...

the include file i made has just the rewrite commands i displayed for you.
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18812683
In what section of Apache it is included?
0
 
LVL 5

Author Comment

by:Oscurochu
ID: 18813230
i already told you, httpd.conf
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18813310
In httpd.conf there are many sections I mean <Directory> <VirtualHost> or just global?
0
 
LVL 5

Author Comment

by:Oscurochu
ID: 18821528
oh, global.
0
 
LVL 27

Accepted Solution

by:
Nopius earned 500 total points
ID: 18821576
Ok.
1) Open your httpd.conf again and find <Directoru /.../htdocs> section - your document root directory
2) Place these directives inside <Directory .../htdocs> section:
RewriteEngine On
RewriteBase /
RewriteRule ^error/([0-9]+)$ error-pages/$1.php

3) Leave RewriteLog and RewriteLogLevel in global section

That's my configuration:
...
RewriteLog /tmp/rewrite.log
RewriteLogLevel 5
<Directory "/u10/v/vA0/usr/htdocs">
RewriteEngine On
RewriteBase /
RewriteRule ^error/([0-9]+)$ error-pages/$1.php
...
4) Remove all .htaccess files from your htdocs directory

I just tested it and it works here.
0

Featured Post

ATEN's HDBaseT Presentation at InfoComm 2017

Hear ATEN Product Manager YT Liang review HDBaseT technology, highlighting ATEN’s latest solutions as they relate to real-world applications during her presentation at the HDBaseT booth at InfoComm 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question