Link to home
Start Free TrialLog in
Avatar of jezella
jezellaFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Apachie mod_rewrite - How to setup

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
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

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.
Avatar of jezella

ASKER

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
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.
Avatar of jezella

ASKER

Yes this is true what you say. I've added a pdf of the phpinfo output.
phpinfo--.pdf
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.

Avatar of jezella

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of onemadeye
onemadeye
Flag of Indonesia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jezella

ASKER

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.