Ravi Kumar
Ravi Kumar

Reputation: 190

Rewrite the url using htaccess in wordpress

I am new to WordPress, creating the custom taxonomy for location in the my current URL

http://localhost/myproject/locations/us

i am need to change the URL like in that location place rename to my-project

i am trying to change the URL using Rewrite rule in ht-access file

RewriteRule ^my-project/us?$ http://localhost/myproject/locations/us [R=301,NC,L]

but its not working any one help me?

Upvotes: 0

Views: 59

Answers (1)

DanieleAlessandra
DanieleAlessandra

Reputation: 1555

Custom .htaccess in WordPress site can bring unexpected results.

You may instead use WordPress' specific Rewrite API

Edit: if you need to use .htaccess insert your rules before the WordPress' ones.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^my-project/us?$ http://localhost/myproject/locations/us [R=301,NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

This is the final .htaccess code, i tested this solution here and it works correctly.

If this solution didn't solve your case maybe there is a problem elsewhere.

Upvotes: 1

Related Questions