Forum Moderators: phranque
Currently my site rewrites my urls from
example.com/years.php?from=1890&to=2007
to
example.com/years/1890-2007
using this in my .htaccess file
RewriteRule ^Years/([^-]*)-([^-]*)$ /Years.php?from=$1&to=$2 [L]
now for my problem...
I have a form on my site that uses method=get so users can enter in a start and end year to get the results - so when someone uses that they will still get the full (non sef) url. Is there a way to redirect every url in that format to the new one so it would go automatically without duplicate pages?
Thanks for the help.
> Is there a way to redirect every url in that format
Sorry, but what format? It's a bit difficult to answer without an example. :)
Jim
{My site] automatically gives the results for every [team] football game from 1894-2007. The user can also pick a range of years from the form on the right column. I have used mod_rewrite to make the urls look like this.
http://www.example.com/YearlyResults/1990-1997
instead of
http://www.example.com/YearlyResults.php?from=1990&to=1997
The only problem is when I use the form it still sends you to the original url with the?from=year&to=year instead of the shortened version. Is it possible to forward those results to the correct rewritten page using .htaccess?
So it will alway redirect
yearlyresults.php?from=xyz&to=yyyy
to
YearlyResults/xyz-yyyy
Thanks for your help.
[edited by: jdMorgan at 5:14 pm (utc) on Oct. 17, 2007]
[edit reason] No personal domains or searchable terms, please. [/edit]
This thread [webmasterworld.com] describes the three-step process, including changing the links on your pages and mod_rewrite code, to implement search-engine-friendly URLs.
Jim
I have setup the .htaccess file to rewrite dynamic pages into the format I want - All of my links are (or will be) setup to the new SEF urls. I'm having trouble with the 301 redirect on dynamic pages though. I have done 301 on my pages that stay the same each time.
ex. example.php?board=a to /board/a/ but can't find how to redirect items that would change. Do I have to setup a 301 for every possible combination of requests?
Example... Everytime someone puts in a link to Yearly.php?from=A&to=B it would transfer them to yearly/A-B. I have no problem putting in that one combination, but what if they put in A-C or C-F do I have to put a redirect to all of them or is there a shorter way to do it?
The only time It will even go to the dynamic url is when someone uses a form to get the years - I can't figure out how to make a form return a url such as 2000-2007 instead of?from=2000&to=2007.
You can use regular-expressions pattern-matching and 'back-references' to make one rule handle many combinations of URL-path elements and query-string values. This is also demonstrated in the cited thread.
Jim