0

I am trying to redirect from source url to target url using regex but it didn't work. Here i describe my problem -

Source URL:

http://example.com/forums/forum/lisa-goran-bygger-hus-t5075/

Target URL:

http://example.com/forums/details/lisa-goran-bygger-hus/

want to redirect without -t5075 from url.

htaccess rewrite rule is:

RewriteRule ^/forums/forum/([a-z-]+[^-t0-9]) /forums/details/$1 [R=301,L]

this isn't work its redirect to me -

http://example.com/forums/details/lisa-goran-bygger-hus-t5075/

Here regex online tester link -

http://www.regextester.com/?fam=97698

What i am doing wrong can someone help me out and explain about this problem.

Thanks

2
  • 1
    why down vote !! i tried last 3 hours solve out this problem so after that i ask here. plz explain whats wrong in this question i will fix up. Commented May 23, 2017 at 12:15
  • Just upvoted in order to cancel someone's downvote, which is not justified here (especially without any explanation) Commented May 23, 2017 at 12:22

1 Answer 1

1

First, make sure mod_rewrite is enabled and htaccess files allowed to be executed.

Then, make sure .htaccess file is in root folder and look like this

RewriteEngine On
RewriteRule ^forums/forum/(.+)-t[0-9]+/$ /forums/details/$1/ [R=301,L]

Finally, try clearing your browser's cache. Indeed, your old rules could interfere. After that, it should work.

Sign up to request clarification or add additional context in comments.

1 Comment

it works thanks for your help and i added regex for global detection like RewriteRule ^forums/forum/(.+)-(t[0-9]*) /forums/details/$1/ [R=301,L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.