Solved

Apachie mod_rewrite - How to setup

Posted on 2011-03-25
8
290 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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
 
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…

777 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