mod rewrite in htaccess file not working

I must be missing something here, but I cannot get the standard wordpress mod rewrite hataccess file to work. Here is what seems relevant:

Excerpts from my httpd.conf file

LoadModule rewrite_module modules/mod_rewrite.so
AllowOverride All
AccessFileName .htaccess

With those settings it seems like the Apache config looks good, so here is the .htaccess file:

# BEGIN WordPress
 <ifmodule mod_rewrite.c="">RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</ifmodule> 

# END WordPress

I appreciate any help that anyone might have. Thanks!!!

4 Replies

You don't want to have ".c" suffix in IfModule clause. You need to mirror module name from LoadModule section, i.e. rewrite_module.

Thanks for the reply, but that is working for me either, here is what I've tried so far in addition to the default file:

# BEGIN WordPress
 <ifmodule rewrite_module="">RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</ifmodule> 
# END WordPress

and

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

@cyphun:

Thanks for the reply, but that is working for me either I guess you mean it does not work for you.

Ok then, keep with the latter (without IfModule) and post your error. If it is 404, 403 or something like that, you have error in your rule (denied access to index.php or missing file). If it is 50x, you have a syntax error or not loaded module.

Also try if your .htaccess is working properly - try to deny or allow access to all and see if something changes.

You do not write which distro you use but is it possible you don't have rewrite module at all (no .so file) or it isn't in specified directory?

Don't forget to check /var/log/apache/error_log to see if there isn't any clue.

Alright, so I figured out the issues with all of this. First, it isn't a good idea to transfer a website between servers when you are half asleep :P

Second, the issue was with my apache configuration. Although I had AllowOverride All set near the area of the config file that talks about htaccess, that wasn't the right spot. I needed to also set the the AllowOverride All within the area:

 <directory>Options FollowSymLinks
AllowOverride All</directory> 

Lastly for anyone having issues with the format of the actual htaccess file this is what I ultimately ended with in my htaccess file:

# BEGIN WordPress
 <ifmodule rewrite_module="">RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</ifmodule> 
# END WordPress 

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct