LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-01-2009, 10:02 AM   #1
slims7
LQ Newbie
 
Registered: Sep 2008
Posts: 9

Rep: Reputation: 0
How to use mod_rewrite to create clean URLs ?


MY Apache is on Centos 5.2

It is installed here:
/etc/httpd.

Modules are in:
/etc/httpd/modules

I searched a lot but I did not found how to install mod_rewrite.

I want to do url cleaning.

Can you help me please?

Slims
 
Old 04-01-2009, 12:53 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,902

Rep: Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611
It should be already installed. Run
Code:
httpd -M
to verify that is installed. Then you can use
Code:
LoadModule rewrite_module modules/mod_rewite.so
to load the module
 
Old 04-02-2009, 02:03 PM   #3
slims7
LQ Newbie
 
Registered: Sep 2008
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bathory View Post
It should be already installed. Run
Code:
httpd -M
to verify that is installed. Then you can use
Code:
LoadModule rewrite_module modules/mod_rewite.so
to load the module

Hi bathory,

When i run command 'httpd -M', the output is

root@tech [~]# httpd -M
Loaded Modules:
core_module (static)
authn_file_module (static)
authn_default_module (static)
authz_host_module (static)
authz_groupfile_module (static)
authz_user_module (static)
authz_default_module (static)
auth_basic_module (static)
include_module (static)
filter_module (static)
log_config_module (static)
logio_module (static)
env_module (static)
expires_module (static)
headers_module (static)
setenvif_module (static)
proxy_module (static)
proxy_connect_module (static)
proxy_ftp_module (static)
proxy_http_module (static)
proxy_ajp_module (static)
proxy_balancer_module (static)
ssl_module (static)
mpm_prefork_module (static)
http_module (static)
mime_module (static)
status_module (static)
autoindex_module (static)
asis_module (static)
info_module (static)
suexec_module (static)
cgi_module (static)
negotiation_module (static)
dir_module (static)
actions_module (static)
userdir_module (static)
alias_module (static)
rewrite_module (static)
so_module (static)
auth_passthrough_module (shared)
bwlimited_module (shared)
frontpage_module (shared)
php5_module (shared)
Syntax OK

and also the line 'LoadModule rewrite_module modules/mod_rewite.so' is not present in my '/etc/httpd/conf/httpd.conf' file.

Now how to enable or shall we need to install OS once again ? or where I can finf exact required file in my centos 5.2 (final).

I would really appreciate if somebody who can help me.

THank you
regards

Slims
 
Old 04-02-2009, 02:17 PM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,902

Rep: Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611
You don't need the "LoadModule rewrite_module ...", since it's statically compiled into apache. All you need is
Code:
RewriteEngine on
before writing the rewrite rules you want in httpd.conf.
 
Old 04-02-2009, 02:39 PM   #5
slims7
LQ Newbie
 
Registered: Sep 2008
Posts: 9

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bathory View Post
You don't need the "LoadModule rewrite_module ...", since it's statically compiled into apache. All you need is
Code:
RewriteEngine on
before writing the rewrite rules you want in httpd.conf.
Hey Bathory

I am really new to linux, kindly explain me little clear, as you mentioned above no need of "LoadModule rewrite_module ..." but we need "RewriteEngine on" let me know where the rewrite rule have to implement?

Regards

slims
 
Old 04-02-2009, 02:56 PM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,902

Rep: Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611
What I mean is that since the mod_rewrite is static (i.e. built-in), you don't need the "LoadModule rewrite_module modules/mod_rewite.so" directive in httpd.conf, so there is no need to concern because it's not present.
Now if you want to use mod_rewrite to rewrite URLs you need to enable the module. This is done with the "RewriteEngine on" directive.
After that you can start using the available rewrite rules to do want you want. I suggest you to start reading about mod_rewrite before trying to apply your rewrite rules. A good starting point is the Apache mod_rewrite documentation.

Regards

Last edited by bathory; 04-02-2009 at 02:57 PM.
 
  


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
mod_rewrite basarab1310 Linux - Newbie 1 11-06-2008 08:57 AM
clean URLs with tomcat - mod_rewrite, mod_proxy, or is there a better solution? laggerific Linux - Software 6 09-18-2008 08:17 PM
Create Desktop Links to Web URLs in DFM Mr. Swillis Linux - Desktop 4 06-11-2008 12:43 AM
how to check urls and stop internet urls in network gface Linux - Networking 5 03-24-2005 10:48 PM
mod_rewrite not rewriting urls chr15t0 Linux - General 1 11-09-2003 05:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:10 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