Jump to content

.htaccess question


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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.