2

I moved my wiki from

http://jklatex.square7.de/wiki/doku.php/start

to

http://logicpuzzle.square7.de/start

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]
</IfModule>

# END WordPress

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

Any hints?

  • 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
  • Nice one. Please answer your own question with the solution :) – zigojacko Mar 29 '13 at 12:52
1

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.

  • "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. – MrWhite Dec 18 '15 at 1:36

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.