Steven_Harris_
Steven_Harris_

Reputation: 1121

Wordpress rewrite .htaccess

I'm trying to add a .htaccess file so Wordpress can use a custom permalink.

I've added the following script to my root, which is located in /web:

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

Although I've added the .htaccess file with this to the root, it still doesn't seem to work.

Am I missing something out?

Upvotes: 0

Views: 64

Answers (3)

MagRat
MagRat

Reputation: 308

Looks like you are missing the last RewriteRule and closing tag. RewriteRule . /index.php [L] and the closing </IfModule> tag.

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

Once you have added this in, go to the permalinks page in the admin area. Loading this page will refresh your permalinks. After that you should be all set.

Upvotes: 0

user2895410
user2895410

Reputation: 11

The one that we use on our site looks like this:

# 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

The BEGIN and END WordPress look like comments to me, but maybe they are needed by someone along the way. Also, on our site, the .htaccess is permissions 644 (chmod 644 .htaccess) and is owned by apache. Hope that helps.

Upvotes: 0

user2672373
user2672373

Reputation:

Here is a checklist for you

  1. Ensure mod_rewrite is enabled
  2. If using Fedora, SuSE, or CentOS ensure that selinux is configured
  3. Ensure that AllowOverride is set to All in httpd.conf

Upvotes: 1

Related Questions