简体   繁体   中英

Rewriting Wordpress URL

Whats the best way to add a url rewrite for wp-login.php to become /login and wp-login.php=action?register to become /register

I tried to add one but seems like i was getting server errors..

At the moment my .htaccess file looks like this. . -

# BEGIN WordPress
# END WordPress
#
AuthType Basic
AuthName "2"
AuthUserFile "/home/site/.htpasswds/public_html/passwd"
require valid-user

Any help would be much appreciated

Add this to your .htaccess file

RewriteEngine on

# Redirect /wp-login.php to /login
RewriteCond %{THE_REQUEST} \ /wp-login\.php\s [NC]
RewriteRule ^ /login [R=301,L]

# Resolve /login to /wp-login.php
RewriteRule ^login/?$ /wp-login.php [NC,L]

# Pass any css/js requests directly
RewriteRule ^login/(.+)$ /$1 [NC,L]

# Redirect register action request to /register
RewriteCond %{THE_REQUEST} (&|\?)action=register(\s|&) [NC]
RewriteRule ^ /register? [R=301,L]

# Resolve /register with /wp-login.php again
RewriteRule ^register/?$ /wp-login.php?action=register [QSA,NC,L]

# Pass any css/js requests directly
RewriteRule ^register/(.+)$ /$1 [NC,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM