1

I am working on a website that uses DokuWiki and the website is called MiscWiki.

Currently all of the URLs are structured this way

http://www.miscwiki.org/doku.php/something/something

I would like to use a .htaccess rewrite to remove the doku.php from the URL. I currently have this statement but it is not working.

RewriteRule ^([^/]+)/doku.php/?(.*)$ /$1 [R=301,L]

Thank you for the help on this one.

1 Answer 1

1

You can use these rules in your site root .htaccess:

AcceptPathInfo On
RewriteEngine On

## Uncomment next 2 lines only when you want to remove doku.php/ from old links
#RewriteCond %{THE_REQUEST} \s/+doku\.php/(\S*) [NC]
#RewriteRule ^ /%1 [R=301,NE,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ doku.php/$0 [L]
Sign up to request clarification or add additional context in comments.

4 Comments

This works well and answers the question, but it causes a problem I did not predict. Links on the site that have the old URL structure now do not work. Is there a way to make this work, whilst preserving old links that still contain doku.php?
On the homepage of miscwiki.org, the links in blue now no longer work and I think it is because they still contain doku.php.
ok I commented out first redirect rule. You can test after clearing browser cache.
Thank you for all the help, I will keep working on this problem and see if I can come to a solution. All the best

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.