Forum Moderators: phranque
I'm very new to htaccess so please be gentle with me :)
I recently changed the format of my forum.
The old url looked like this :
[domain.tld...]
Now it looks like this
[domain.tld...]
I would like to use htaccess to change search engine results coming in to the old setup and have it automatically direct the visitor to the new url.
Is this something I can use htaccess to do?
If so, I would be very grateful if you could give me an example of what I would need to include.
Many thanks
Fizz
This recent thread [webmasterworld.com] may help you to focus-in on your problem more precisely.
The short answer is, "Yes, mod_rewrite can do that." - It's defining the "do that" part that is the initial problem.
If that thread helps you define your goal, then re-post back here.
Also, a good general introduction is also available in our Introduction to mod_rewrite [webmasterworld.com] tutorial -- Follow the links to the mod_rewrite documentation and the Regular-Expressions tutorial cired in the first post of that thread.
Jim
Thanks for those links.
I've been trying to get my head around the info but it doesn't seem to be sticking.
The problem seems to be that the "909" part of the url is a dynamic so that would need to be numbers all the time but the numbers would change deoending on the thread number that the redirect had to go to.
I tried this
RewriteEngine On
RewriteRule ^http://www.domain\.tld/yabbse/index\.php\?thread=(.*)$ [domain.tld...] [L]
but that didn't work.
Do you have any suggestions where I might be going wrong?
Thanks
Fizz
You could use:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^thread=([0-9]*)$
RewriteRule ^yabbse/index\.php$ http://www.example.com/yabbse/index.php/[b]t%1[/b].php [b][R=301,L][/b]
RewriteEngine On
RewriteRule ^yabbse/index\.php$ http://www.example.com/yabbse/index.php/[b]t%{QUERY_STRING}[/b].php [b][R=301,L][/b]
Jim
Wow! what an improvement Thank you :)
I used the option
RewriteCond %{QUERY_STRING} ^thread=([0-9]*)$
RewriteRule ^yabbse/index\.php$ [site.com...] [R=301,L]
The search engine results are now feeding in to the thread in the forum with one small glitch.
For some reason the Query_String seems to be repeating itself
The results appear like this
[site.com...]
The bit after the? seems to carry over from the query string but the url would normally look like this
[site.com...]
I tried dropping
RewriteCond %{QUERY_STRING} ^thread=([0-9]*)$
to
RewriteCond %{QUERY_STRING} ^([0-9]*)$
but that caused it to stop working,
It's nearly perfect, can you suggest where I can look to stop the doubling up?
Many thanks
Fizz
Doh! I always forget that part... :o
Adding a "?" to the end of the substitution will fix that.
RewriteCond %{QUERY_STRING} ^thread=([0-9]*)$
RewriteRule ^yabbse/index\.php$ http://www.site.com/yabbse/index.php/t%1.ph[b]p?[/b] [R=301,L]
Jim
You are an absolute genius!
That? on the end did the trick perfectly, the urls are resolving a treat and I have you to thank for that.
If there was some sort of "reward" system here then you would certainly be at the top of the list. The help you gave was clear and concise enough for a newbie like me to follow easily and you took the time to explain what was going on. That makes all the difference to people like me.
Take a bow Jim. You deserve it.
Many thanks
Fizz