LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-03-2010, 11:50 AM   #1
saifurab
Member
 
Registered: Mar 2007
Posts: 30

Rep: Reputation: 15
mod_rewrite and Apache


CentOS release 5.4 (Final)
Server version: Apache/2.2.3
PHP 5.1.6

I have this line in my httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so

and also

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>

and if see phpinfo(), this also shows mod_rewrite module is installed.

i used this link

Code:
http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html
to test mod_rewrite but i get 404 error.

Please help

Saif
 
Old 09-03-2010, 12:23 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,272

Rep: Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692
Hi,

Check apache error_log to see what file it looks for and gives the 404 error. To see if you have mod_rewrite enable, run:
Code:
httpd -M|grep rewrite
Re. the error, are you sure you did the copy/paste correctly? Also the name of the file must be rewrite.php if you want the RewriteRule to work.

Lastly, it's better to leave "AllowOverride None" for the "/" directory and use "AllowOverride All" for /var/www/html.

Regards
 
Old 09-03-2010, 10:29 PM   #3
saifurab
Member
 
Registered: Mar 2007
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
# httpd -M |grep rewrite
Loaded Modules:
core_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
auth_basic_module (shared)
auth_digest_module (shared)
authn_file_module (shared)
authn_alias_module (shared)
authn_anon_module (shared)
authn_dbm_module (shared)
authn_default_module (shared)
authz_host_module (shared)
authz_user_module (shared)
authz_owner_module (shared)
authz_groupfile_module (shared)
authz_dbm_module (shared)
authz_default_module (shared)
ldap_module (shared)
authnz_ldap_module (shared)
include_module (shared)
log_config_module (shared)
logio_module (shared)
env_module (shared)
ext_filter_module (shared)
mime_magic_module (shared)
expires_module (shared)
deflate_module (shared)
headers_module (shared)
usertrack_module (shared)
setenvif_module (shared)
mime_module (shared)
dav_module (shared)
status_module (shared)
autoindex_module (shared)
info_module (shared)
dav_fs_module (shared)
vhost_alias_module (shared)
negotiation_module (shared)
dir_module (shared)
actions_module (shared)
speling_module (shared)
userdir_module (shared)
alias_module (shared)
rewrite_module (shared)
proxy_module (shared)
proxy_balancer_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_connect_module (shared)
cache_module (shared)
suexec_module (shared)
disk_cache_module (shared)
file_cache_module (shared)
mem_cache_module (shared)
cgi_module (shared)
version_module (shared)
perl_module (shared)
php5_module (shared)
proxy_ajp_module (shared)
python_module (shared)
ssl_module (shared)
and rewrite.php

Quote:

<?php /* mod_rewrite Test Page *//* Copyright 2006 Webune.com */

if($_GET['link']==1){
echo '<span style="color:red">You are not using mod_rewrite - Try LINK2</span>';
}
elseif($_GET['link']==2){echo'<span style="color:green">Congratulations!! You are using Apache mod_rewrite</span>';}

else{echo '<span style="color:blue">Linux Apache mod_rewrte Test Tutorial</span>';} ?>
And when I did AllowOveride All for /var/www/html and i tried to open http://domainame/test/rewrite.php, i receive 500 error

And if you have any simple example to test please let me know. Since, I am sys admin not programmer

Last edited by saifurab; 09-03-2010 at 11:44 PM.
 
Old 09-04-2010, 08:08 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,272

Rep: Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692Reputation: 1692
Hi,

The easiest way to test, is to redirect a non existing page to an existing one, e.g:
Code:
RewriteEngine On

RewriteRule nonexistent.html index.html
Regards
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache and mod_rewrite Elguapo Linux - Software 1 08-09-2007 03:24 AM
How to enable Apache mod_rewrite, after apache installed without this modue jCash Linux - Newbie 1 10-24-2006 10:23 AM
Apache Mod_rewrite help! soulsniper Linux - Software 0 01-16-2005 05:23 PM
Apache:mod_rewrite MadMikie Linux - Software 0 08-03-2004 07:33 AM
Apache and mod_rewrite notsoevil Linux - General 0 01-23-2002 01:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration