2

after setting up the wordpress htaccess rules in my vhost, i was unable to enter the wp-admin area. I was always redirected to the frontpage of my wordpress instance.

The rewriting itself worked on the mainpage. All links worked so far, but the admin area remains without any access.

Rewrite rules used:

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

Personally i dont know where to start looking, im even unable to find that problem over google, which is kinda rare - maybe someone over here knows where the problem is to be located.

  • Did you add a new htaccess file? I might be able to help you if I know what you were trying exactly. – Rutwick Gangurde Mar 22 '12 at 10:16
  • Internally we do not use .htaccess files, we do all the configuration based on the servers vhost file (which essentially has the same effect). I simply want to get permalinks working. Which partially i did, the links worked, but i wasn't able to log in to the backend ( /wp-admin/ ) after "installing" the rewrite rule – Sam Mar 22 '12 at 10:21
  • Sorry, can't help you in that case! Not very familiar with server config and stuff. Just a try, try.../wp-login.php instead of .../wp-admin. – Rutwick Gangurde Mar 22 '12 at 11:56
2

OK, so the initial Problem was: How to get the Rewrite Rule working at a VHOST Environment and the answer - if unknown - was a little tricky. RewriteBase doesn't work on a VHOST. The Solution is to put all those Rewrite-Stuff at a Directory-Section like this:

<VirtualHost *:80>
  ServerName www.mydomain.tld
  ...more config stuff...

  <Directory "/var/www/mydomain">
    RewriteEngine On
    RewriteBase /

    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
  </Directory>
</VirtualHost>

Then it works. I'll be updating the questions title for better google results in the future. Hope this may help anyone running into the same troubles.

  • is it still the case in 2018? I'm currently having hard time with permalinks and vhosts ... – davideghz Apr 3 '18 at 14:55
1

I'm not sure if this helps but its good practice, include the BEGIN and END WordPress comments around your rules as well as the check for mod_rewrite:

# 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

Also:

  • Do not apply these rules until you have chosen and saved permalinks in the admin area, only once you have done this should you setup the .htaccess file
  • The Comments are used by plugins to allow rewriting of the htaccess file without messing up the core wordpress rules
  • Make sure your rewrite base is set correctly
0

I'm using the following in my vhost configuration, with this you can use the .htaccess file in your project directory:

<Directory "YOUR-PROJECT-PATH">
    Options FollowSymLinks Includes ExecCGI
    AllowOverride All
    DirectoryIndex index.html index.htm index.php
</Directory>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.