Code Lover
Code Lover

Reputation: 8348

Redirect Rule not working

I am trying to redirect wordpress default login (wp-logiin.php) url to signin but somehow it is not working. I have never done this .htaccess rewrite rule before so no idea how it works.

# BEGIN WordPress
RewriteRule ^signin$ http://localhost/newsite/wp-login.php [NC,L,R]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /newsite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /newsite/index.php [L]
</IfModule>

# END WordPress

Big Big thanks

Upvotes: 0

Views: 229

Answers (2)

drobik
drobik

Reputation: 81

Try to read manual :) http://httpd.apache.org/docs/current/mod/mod_rewrite.html


First of all, if you want to use "rewrite", condition must be defined first, followed by rule which is used if is condition met. For example:

RewriteCond %{HTTP_USER_AGENT} ^facebookexternalhit [OR,NC]
RewriteCond %{HTTP_USER_AGENT} ^Zeus [NC]
RewriteRule ^.* /errors/404.html [F]

RewriteRule ^signin$ http://localhost/newsite/wp-login.php [NC,L,R]<br>

Use of RewriteRule without defined RuleCondition, thus IMHO this rule will not be used, never.


RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteCond %{REQUEST_FILENAME} !-d<br>
RewriteRule . /newsite/index.php [L]<br>

As say manual "Pattern is a perl compatible regular expression.", thus single "." as pattern mean one single character. So, if request filename will be "test.txt", it will replace every letter with "/newsite/index.php" (8 chars = 8x repeat).
Correct version is: RewriteRule ^.*$ /newsite/index.php [L]

Upvotes: 2

Jon Lin
Jon Lin

Reputation: 143906

You're redirecting logins to localhost, so unless you're using a browser from the same machine that your wordpress site is running on, you're probably going to get a connection error. Try removing the http:// bit from your rule:

RewriteRule ^signin$ /newsite/wp-login.php [NC,L,R]

Upvotes: 1

Related Questions