Jump to content

Recommended Posts

I was using this rewrite rule in my .htaccess for my courses page:

 

RewriteRule ^([^/\.]+)/region/([^/\.]+)/?$ index.php?uk=$1&region=$2 [L]

output: area/region/sample_area

 

I have changed the structure of the URL's mainly because of seo. I have now added this rule which is:

 

RewriteRule ^course([^/\.]+)/([^/\.]+)/?$ index.php?region=$2&uk=$1 [L]

output: coursearea/sample_area

 

The problem I have now is that this page now has 2 url's with the same content on. I cannot simply delete the first rewrite rule as it is still on Googles search results. So I am wanting to redirect

 

area/region/sample_area    to    coursearea/sample_area

 

I have no idea how to do this, have tried everything. Any ideas appreciated!

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/203089-htaccess-question/
Share on other sites

I think you want something like this...

 

RewriteRule ^([^/\.]+)/region/([^/\.]+)/?$ course$1/$2 [R=302]

 

Once you know it's linking you to the right page you can change the 302 (temporary forward) to a 301 (permanent forward), but doing so before hand will make it hard to test/debug.

 

 

Link to comment
https://forums.phpfreaks.com/topic/203089-htaccess-question/#findComment-1064153
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.