regex - 301 redirect to full path -


i have lot incorrect links, links pointing to:

http://www.domain.com/tags/keyword

while correct path is

http://www.domain.com/tags/keyword/

there hundreds of those...how 301 redirect wrong links correct links?

thank in advance

you can try code:

rewritebase / rewriterule ^tags/([^/]+)$ /tags/$1/ [l,r=301] 
  • rewritebase / tells apache uri starts /. if site in subfolder should write rewritebase /subfolder/ instead.
  • ^tags/([^/]+)$: search uri starting tags/ followed [^/]+ means characters except /. ( ) around there capture , use in redirection. capture characters not / between tags/.../ in uri. (^ marks start of string while $ marks end)
  • /tags/$1/ redirection. $1 means first previous captured element (the 1 witch between ( )).
  • [l,r=301] indicates apache should stop process other rules , redirect 301 header code.

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -