My directories are like:
http://www.mydomain.com/macbook-computer
http://www.mydomain.com/sony-computer
http://www.mydomain.com/lenovo-computer
I want to make that, if a user type computers/macbook-computer like:
http://www.mydomain.com/computers/macbook-computer
I want to display page which is : http://www.mydomain.com/macbook-computer
.
My restrictions are:
1. User must type /computers (segment 1)
2. String coming from computers/ must end with "computer". (segment 2)
How can I make this achieve in my .htaccess file?
You need a rewrite rule in your .htaccess file, and a little regular expression magic. Something like this should do the trick
Here's a nice online tool for checking rewrite rules
http://htaccess.madewithlove.be/
You may try this:
Redirects permanently
http://www.mydomain.com/computers/anyname-computer
with or without trailing slash.To:
http://www.mydomain.com/anyname-computer
Strings
computers
andcomputer
are assumed to be fixed, whileanything
is assumed to be variable.The incoming URL structure has to be kept for the rule-set to work: First folder
/computers
followed by/anyname-computer
.For silent mapping, remove
R=301
from[R=301,L]