Forum Moderators: phranque
Since in many of my urls i have characters like čćđžš, i want to use SEO version of those letters (c,c,d or dj, z, s). i'll make an extra field in my db and that's ok.
now, i want to have urls like this (many combinations are possible):
www.example.com/show.php?cat=1&make=Toyota
www.example.com/show.php?cat=1&make=Toyota&model=Avensis
www.example.com/show.php?cat=1&make=Toyota&model=Avensis&color=white
www.example.com/show.php?cat=1&make=Toyota&model=Avensis&color=white&page=4
NOTE: currently, i'm interested in making SEO friendly only this "make" parameter. My redirects should also be working if the parameter is omitted, eg.
www.example.com/show.php?cat=1&make=&model=Avensis&color=white
(although this is not a very good example (since no other make has model Avensis), i think you got the idea)
The reason i want to make temporary redirection is Google. I dont want my visitor get stuck with blank page.
So, if anyone here has any idea, I'll appreciate it a lot!
Thanks!
We simply need a 'map' of some 'old URLs', the corresponding 'new' URLs, and the server filepaths to which they are to be resolved.
Then we need to see the code you've tried to implement, and a description of how it goes wrong.
If any of the above is unclear, please refer to our Forum Charter.
Thanks,
Jim
www.example.com/cat/toyota/avensis/white/4 Note: all lower-case, folder-like URLs, no cruft, no query-string parameters. Use + or - (never hyphen or space) for multi-word values.
Mod_Rewrite is the right tool to make that happen.
let me try this way. i want to tell .htaccess to redirect temporarily (until google indexes changed URLs) an url like this:
example.com/show.php?cat=1&make=Škoda
to
example.com/show.php?cat=1&make=Skoda
because i want only english alphabet characters a-z in my URLs
after i resolve this issue, i'll try to make all my urls SEO friendly, ie. example.com/show/cat/1/make/skoda/, but only after Google indexed my new URLs
hope this helps
Thanks
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /show\.php\?cat=1&make=\%23269;koda\ HTTP/
RewriteRule ^show\.php$ http://example.com/show.php?cat=1&make=Skoda [R=301,L]
A "shortcut" to determine the proper pattern for the RewriteCond would be to look at your raw server access log file, copy the client-requested URL+query string from there, and then apply the required regular-expressions escaping to it. Note that the "[A-Z]+" subpattern is intended to match the HTTP method in the request line, such as "GET", and the unanchored "\ HTTP/" subpattern at the end of the pattern is intended to match either " HTTP/1.0" or " HTTP/1.1" at the end of the client request line.
Jim
after I resolve this issue, I'll try to make all my URLs SEO friendly, i.e. example.com/show/cat/1/make/skoda/, but only after Google indexed my new URLs
After they have indexed your "new" URLs they will have to scrap all that and the re-index your yet newer friendly URLs from scratch.
You'll then need to set up two sets of redirects: one for the oldest URL format, and another for this intermediate URL format that you are proposing in this thread.
That is double the work for you, and double the risk of your rankings tanking, due to either some technical mistake and/or Google taking exception to the content moving to a new URL and then moving again shortly after.
I would recommend moving to new friendly URLs now, and adding redirects for all non-canonical formats so thet you move once and only once.
I am not sure that a temporary redirect is what you want either. I would suggest that all of the redirects be permanent i.e. 301. Or, do you mean by 'temporary' that you only want the redirect in place for a short time?
@jdMorgan, i managed to get all right as you suggested.
but, there's a catch, i dont know how big or small it might be.
it would be very difficult to address every possible parameter combination. is there any way of telling the script that i want only one parameter ("make") matched, no matter how many other parameters there might be after (or somewhere else) it?
for now, im able to match this:
example.com/show.php?cat=1&make=Škoda with
example.com/show.php?cat=1&make=Škoda
but when there is such an url:
example.com/show.php?cat=1&make=Škoda&model=Superb, i want it to redirect to the proper url without having to explicitly saying to the engine which other parameters are and what combination of them might occur.
in other words, i want only a portion (ie, the crucial part) of url to be matched.
Hope you get it. if not, feel free to ask.
Thanks man!
EDIT:
here's a working example:
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /prikazi\.php\?ktg=1&djelatnost=Poljoprivreda\+\-\+Ribarstvo\+\-\+\%C5\%A0umarstvo\ HTTP/
RewriteRule ^prikazi\.php$ [blah-blah.net...] [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /show\.php\?(([^&\ ]+&)*)make=\%23269;koda((&[^&\ ]+)*)\ HTTP/
RewriteRule ^show\.php$ http://example.com/show.php?[b]%1[/b]make=Skoda[b]%3[/b] [R=301,L]