Forum Moderators: phranque
This is one of my 'stabs in the dark':
Options +FollowSymLinks
RewriteEngine on
#
# If the client requests a dynamic URL, externally redirect the client to a static URL
RewriteCond %{QUERY_STRING} ^mainpage=([^&]+) [NC]
RewriteRule ^/index\.php$ /%1.html? [R=301,L]
The internal rewrites are as follows. I'm not expecting answers to all (although that would be very nice!), but a nudge in the right direction with a couple examples would be great. :)
RewriteBase /
RewriteRule ^skin-care/(.*)notify_remove\.html /index.php?main_page=product_info&products_id=$1&action=notify_remove [L]
RewriteRule ^skin-care/(.*)notify\.html /index.php?main_page=product_info&products_id=$1&action=notify [L]
RewriteRule ^skin-care/(.*)add\.html /index.php?main_page=product_info&products_id=$1&action=add_product [L]
RewriteRule ^skin-care/(.*)\.html /index.php?main_page=product_info&products_id=$1 [L]
RewriteRule ^skincare-range/(.*)/filter(.*)/page(.*)/sort(.*)\.html /index.php?main_page=index&cPath=$1&filter_id=$2&page=$3&sort=$4 [L]
RewriteRule ^skincare-range/(.*)/sort(.*)/filter(.*)/page(.*)\.html /index.php?main_page=index&cPath=$1&sort=$2&filter_id=$3&page=$4 [L]
RewriteRule ^skincare-range/(.*)/filter(.*)/sort(.*)/page(.*)\.html /index.php?main_page=index&cPath=$1&filter_id=$2&sort=$3&page=$4 [L]
RewriteRule ^skincare-range/(.*)/sort(.*)/filter(.*)\.html /index.php?main_page=index&cPath=$1&sort=$2&filter_id=$3 [L]
RewriteRule ^skincare-range/(.*)/sort(.*)/page(.*)\.html /index.php?main_page=index&cPath=$1&sort=$2&page=$3 [L]
RewriteRule ^skincare-range/(.*)/page(.*)/sort(.*)\.html /index.php?main_page=index&cPath=$1&page=$2&sort=$3 [L]
RewriteRule ^skincare-range/(.*)\.html /index.php?main_page=index&cPath=$1 [L]
RewriteRule ^order/(.*)\.html /index.php?main_page&action=buy_now&products_id=$1 [L]
RewriteRule ^(.*)/display(.*)_(.*)\.html /index.php?main_page=$1&disp_order=$2&page=$3 [L]
RewriteRule ^shippinginfo\.html /index.php?main_page=shippinginfo [L]
RewriteRule ^privacy\.html /index.php?main_page=privacy [L]
RewriteRule ^conditions\.html /index.php?main_page=conditions [L]
RewriteRule ^contact_us\.html /index.php?main_page=contact_us [L]
RewriteRule ^gv_faq\.html /index.php?main_page=gv_faq [L]
RewriteRule ^site_map\.html /index.php?main_page=site_map [L]
RewriteRule ^specials\.html /index.php?main_page=specials [L]
RewriteRule ^suppliers\.html /index.php?main_page=suppliers [L]
RewriteRule ^unsubscribe\.html /index.php?main_page=unsubscribe [L]
RewriteRule ^featured_products\.html /index.php?main_page=featured_products [L]
RewriteRule ^products_new\.html /index.php?main_page=products_new [L]
RewriteRule ^products_all\.html /index.php?main_page=products_all [L]
RewriteRule ^tell_a_friend/to_(.*)/products(.*)\.html /index.php?main_page=tell_a_friend&to_email_address=$1&products_id=$2 [L]
RewriteRule ^tell_a_friend/products(.*)\.html /index.php?main_page=tell_a_friend&products_id=$1 [L]
RewriteRule ^product_reviews/products(.*)\.html /index.php?main_page=product_reviews&products_id=$1 [L]
RewriteRule ^product_reviews\.html /index.php?main_page=product_reviews [L]
RewriteRule ^manufacturers_id(.*)\.html /index.php?main_page=index&manufacturers_id=$1 [L]
RewriteRule ^redirect/manufacturers_id(.*)\.html /index.php?main_page=redirect&action=manufacturer&manufacturers_id=$1 [L]
RewriteRule ^redirect_url-(.*) /index.php?main_page=redirect&action=url&goto=$1 [L]
RewriteRule ^login\.html /index.php?main_page=login [L]
RewriteRule ^logoff\.html /index.php?main_page=logoff [L]
RewriteRule ^account\.html /index.php?main_page=account [L]
RewriteRule ^shopping_cart\.html /index.php?main_page=shopping_cart [L]
RewriteRule ^checkout_shipping\.html /index.php?main_page=checkout_shipping [L]
RewriteRule ^advanced_search\.html /index.php?main_page=advanced_search [L]
RewriteRule ^popup_shipping_estimator\.html /index.php?main_page=popup_shipping_estimator [L]
RewriteRule ^index\.html.zenid=(.*)$ /index.php?main_page=index&zenid=$1 [L]
RewriteRule ^index\.html$ /index.php?main_page=index [L]
RewriteRule ^skincare-info/(.*)\.html /index.php?main_page=infopages&pages_id=$1 [L]
[edited by: jdMorgan at 4:55 pm (utc) on Mar. 20, 2005]
[edit reason] Fixed code formatting. [/edit]
# If the client requests a dynamic URL, externally redirect the client to a static URL
RewriteCond %{QUERY_STRING} ^mai[b]n_p[/b]age=([^&]+) [NC]
RewriteRule ^/index\.php$ /%1.html? [R=301,L]
# If the client directly requests a dynamic URL, externally redirect the client to a static URL
RewriteCond %{THE_REQUEST} ^GET\ /index\.php.*\?main_page=([^&]+) [NC]
RewriteRule ^/index\.php$ /%1.html? [R=301,L]
Jim
The first thing I see is that you need to use "main_page", not "mainpage", to be consistent with what your other rules are doing.
To quote "Spinal Tap": It's such a fine line between stupid and clever.
Thanks for taking time to reply, Jim. I think I've read *all* your threads on this topic but still stabbing in the dark. Ho hum. Gonna be dreaming \/.*?^(a-Z)* tonight!
I tried the last statement group - still getting '200 OK' when visiting [mydomain.co.uk...]
My lack of comprehension may reduce lack of description, but I'm aiming to 301, e.g.:
index.php?main_page=shippinginfo -> shippinginfo.html
If a URL would help, happy to PM.
David.
# If the client directly requests a dynamic URL, externally redirect the client to a static URL
RewriteCond %{THE_REQUEST} ^GET\ /index\.php.*\?main_page=([^&]+) [NC]
RewriteRule [b]^in[/b]dex\.php$ [b]http://www.example.co.uk/[/b]%1.html? [R=301,L]
Jim
# If the client directly requests a dynamic URL, externally redirect the client to a static URL
RewriteCond %{THE_REQUEST} ^GET\ index\.php.*\?main_page=([^&]+) [NC]
RewriteRule ^index\.php$ http://www.example.co.uk/%1.html? [R=301,L]
Trying to think of a witty 'spontaneous combustion' response, but that's meeting with same amount of success as my [code] Style Code being applied. :/
[edited by: jdMorgan at 4:00 am (utc) on Mar. 21, 2005]
[edit reason] Examplified. [/edit]
# If the client directly requests a dynamic URL, externally redirect the client to a static URL
RewriteCond %{THE_REQUEST} ^GET\ index\.php.*\?main_page=([^&]+)[b].*\ HTTP[/b] [NC]
RewriteRule ^index\.php$ http://www.example.co.uk/%1.html? [R=301,L]
Jim
I am actually trying to understand the process and not just waiting to be spoon-fed, although it's still a bit hieroglyphic. Something puzzles me about your rule: in the RewriteCond, why the '.*' in 'index\.php.*\?main_page=('? There's never going to be '1 or many characters' at that point?
[sigh] [/code] / [\code] - we're back to that fine line again.
# If the client directly requests a dynamic URL, externally redirect the client to a static URL
RewriteCond %{THE_REQUEST} ^GET\ [b]/i[/b]ndex\.php\?main_page=([^&]+).*\ HTTP [NC]
RewriteRule ^index\.php$ http://www.example.co.uk/%1.html? [R=301,L]
As to understanding, the patterns have to match the request exactly, and because I fat-fingered the code, they didn't.
Jim
However (there had to be, of course), some multi-part URLs (e.g. [MYDOMAIN.co.uk...] now kick back to index.html, while others (e.g. [MYDOMAIN.co.uk...] 404.
I'm thinking all the rewrites I originally listed are going to take some fancy regexing. <snip>
[edited by: jdMorgan at 5:49 am (utc) on Mar. 21, 2005]