Solved

Apachie mod_rewrite - How to setup

Posted on 2011-03-25
8
288 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Yes this is true what you say. I've added a pdf of the phpinfo output.
phpinfo--.pdf
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 50

Expert Comment

by:Steve Bink
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 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

17 Experts available now in Live!

Get 1:1 Help Now