Solved

Apachie mod_rewrite - How to setup

Posted on 2011-03-25
8
289 Views
Last Modified: 2012-05-11
Hello all. I have been to the Apachie site and looked at their docs but remain confused.

I have a testing Apachie server at home working with php with no problems. I am playing around now with Wordpress and want to get the permalinks working but have problems. On my main hosted site everything works fine.

Can someone please walk me through the process of setting mod_rewrite and then testing that it works. What I have done so far is set #LoadModule rewrite_module modules/mod_rewrite.so  to LoadModule rewrite_module modules/mod_rewrite.so in my httpd.conf but this does not seem to work.

Thanks
0
Comment
Question by:jezella
  • 4
  • 3
8 Comments
 
LVL 50

Expert Comment

by:Steve Bink
ID: 35221014
What version of Apache, and what OS?

You can verify mod_rewrite is being loaded by using the -M switch on your control app.  Usually, this is "httpd -M" or "apache2ctl -M", depending on your installation flavor.  If rewrite is loaded, you will see rewrite_module in the output somewhere:

[root@myserver:/home]
#> apache2ctl -M | grep "rewrite"
Syntax OK
 rewrite_module (shared)

Open in new window


Once you are sure rewrite is being loaded, you will need to establish your RewriteRule directives.  These can be very simple, or amazingly complex, depending on your needs.  You can try using the RewriteLog directive to assist with troubleshooting.  If you would like us to assist in that effort, post the rules you have with a detailed explanation of what you want the rule to do.
0
 

Author Comment

by:jezella
ID: 35221303
I'm sorry I ought to have said. Apachie is  5.2.3 and the operating system is windows 7. I'm not sure what the code above means. Do I create a basic page with the code above in place and then run it?. I have the following in my phpinfo.php but not sure if this is anything to do with it.
Capture.JPG
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 35222261
Apache is not v5.2.3.  The most recent version is 2.2.  It sounds like you are reporting your PHP version.  Post the entirety of your phpinfo() output.
0
 

Author Comment

by:jezella
ID: 35222832
Yes this is true what you say. I've added a pdf of the phpinfo output.
phpinfo--.pdf
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 50

Expert Comment

by:Steve Bink
ID: 35223189
On page 3 of that PDF, under the section titled "apache2handler", you will see mod_rewrite listed under "Loaded Modules".  So rewrite should be on target.  The next step is testing it.

There are two ways to set up rewriting.  You can either edit the Apache server's conf file, or, assuming you have allowed for them, edit the .htaccess file for the site you are attempting to manage.  If you have rules already set up, please post them.  Also, explain what sort of redirection you want accomplish, with as much detail as possible.

0
 

Author Comment

by:jezella
ID: 35223292
Thank you for your help on this and I'm sorry for the delayed response. I seem to be having an internet connection problem today.

Code follows for the .htaccess file.


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Open in new window

0
 
LVL 5

Accepted Solution

by:
onemadeye earned 500 total points
ID: 35228642
As you have set this on httpd.conf

#LoadModule rewrite_module modules/mod_rewrite.so
to
LoadModule rewrite_module modules/mod_rewrite.so

Next, in that same httpd.conf file you also need to find:

AllowOverride None
.. and replace it with :
AllowOverride All

It appears 2 or 3 times I guess...
Then the mod rewrite url will be ready for your scripts ..

Regards...
0
 

Author Comment

by:jezella
ID: 35230470
Onemadeve.

YOUR ARE FANTASTIC. I did the AllowOverride None to AllowOverride All in the past and it never worked. The simple fact that you mentioned that this needed to be changed in multiple places did the trick.

Many thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

948 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now