Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I moved my wiki from




and now i want to redirect the URL with mod_rewrite. My .htaccess is as follows:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/wiki/doku.php/(.*)$ http://logicpuzzle.square7.de/$1 [R,NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

I don't understand why it does not work :-(

Any hints?

share|improve this question
Are you definitely using an Apache server? If not, .htaccess may not even be in use. If you rename .htaccess, does your site break? – zigojacko Mar 29 '13 at 11:04
Yes, the server is Apache/2.4 and according to the forum mod_rewrite is active. – Josef Mar 29 '13 at 11:42
After renaming to .htaccess2 nothing special happens. Why should this break the page? – Josef Mar 29 '13 at 11:54
Got it! The problem is the leading slash. RewriteRule ^wiki/doku.php/(.*)$ http://logicpuzzle.square7.de/$1 [R,NC,L] works. – Josef Mar 29 '13 at 12:19
@Josef: Glad you got it resolved. You can put that as an answer (below) and accept it. That way, others will see that the question has been answered (and you have a chance of getting more rep). – w3dk Mar 29 '13 at 12:52
up vote 1 down vote accepted

The leading slash is evil! ;-) The slash is part of RewriteBase.

Changing the RewriteRule to

RewriteRule ^wiki/doku.php/(.*)$ http://logicpuzzle.square7.de/$1 [R=301,NC,L]

works as desired.

share|improve this answer
"The slash is part of RewriteBase" - Just to clarify, the leading slash on the RewriteRule pattern has nothing to do with RewriteBase. In per-directory .htaccess files, the RewriteRule pattern matches against the filesystem/URL path after having removed the directory-prefix. The directory-prefix is the filesystem path of the .htaccess file and always ends with a slash, so the URL-path that matches never starts with a slash. – w3dk Dec 18 '15 at 1:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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