.htaccess redirect with mod_rewrite

.htaccess redirect with mod_rewrite - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, mod-rewrite, , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


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?


Solution :

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.


Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect