Jonathon Hewitt
Forum Replies Created
-
Ok so I figured it out! I just had to add the little $1 at the end of the destination URLs and it works like a charm!
RewriteEngine On RewriteCond %{HTTP_HOST} ^bchyundai.com [NC] RewriteRule ^(.*)$ https://www.bchyundai.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^www.bchyundai.com [NC] RewriteRule browse/view_detailed/type_used/(.*)$ https://usedcars.bchyundai.com/bchyundaiv2/browse/view_detailed/type_used/$1 [R=301,NC,L] RewriteCond %{HTTP_HOST} ^bcmazda.com [NC] RewriteRule ^(.*)$ https://www.bcmazda.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^www.bcmazda.com [NC] RewriteRule browse/view_detailed/type_used/(.*)$ https://usedcars.bcmazda.com/bcmazdav2/browse/view_detailed/type_used/$1 [R=301,NC,L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
The last question I have is; is there a way to make it a one for all redirect, such as you set one redirect for each domain and all slugs would just carry over?
This doesn’t seem to work in this case. I would like it if even sitemap/browse/view_detailed/type_used/ would still trigger the 1st redirect and carry the visitor over to the intended page: https://usedcars.bcmazda.com/bcmazdav2/browse/view_detailed/type_used/ for example. So basically anything that has “browse/view_detailed/type_used/” in the slug would go there nomatter if it had characters before it or after it. And whats after it would carry over to the end of the intended path. An example of this working is:
Please visit: PC AutoMall’s Sitemap Page (just for an example page with some type of slug) and use the inventory search function that is in the top of sidebar to the right, just click “Search Vehicles” (no drop down selection is needed but will work if you select a make or model) and you will notice that the redirect that is in place there will take you right to the intended page with the “browse/view_detailed/type_used/” at the end.
This is what I have set up for the PCAutoMall.com .htaccess right now (the one that works nomatter what the slug):
# BEGIN WordPress Redirect 301 /browse/view_detailed/type_used/ https://usedcars.pcautomall.com/pcautomallv2/browse/view_detailed/type_used/ Redirect 301 /browse/view_detailed/type_new/ https://newcars.pcautomall.com/pcautomallv2/browse/view_detailed/type_new/ <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L] RewriteRule . index.php [L] </IfModule> # END WordPress
So why does this work with PCAutoMall.com but not with BCHyundai.com?
Ok bud sorry for taking a while to update this again and thank you very much as this seems to be even close to perfection. I just have one more question as this is working from the homepage (root domain) but anytime you visit any other page it goes to a 404 page and does not carry over the trailing part of the URL. Example: please visit the Hyundai Sitemap page and then click on the blue search button in the header area (no drop down selection is needed) you will find yourself at the following slug: /sitemap/browse/view_detailed/type_used/ which means that it completely missed the redirect and did not go to the sub-domain either as does now in the root of both sites. If you visit another one of my websites with this same type of search function installed (which is also on a WordPress network) here on the Honda Sitemap page and then you just click “Search Vehicles” in the top right of the sidebar, even though you are on the /sitemap/ slug, the search function seems to trigger the redirect and go to the intended sub-domain and all. I just don’t understand why it works on one site and not the other. Uggg… And btw, can I buy you a cup of coffee or a beer for this? lolz this is a big help to my company being able to utilize WordPress networks for future builds.
Well by the number of downloads you have you must have learned all this stuff the hard way then, trial and error type of thing. Very impressive! And Anthropology is perhaps the most important thing that one can study, I base the study of all other sciences on that one science!
I love WordPress and plan to become a recognized WordPress development company in the automotive industry one day. To give you the short synopsis here:
We are an automotive web design and SEO company and have become resellers of HomeNet Automotive who is a large provider of automotive inventory data for car dealers. They have a “backweb” setup which after a cname record change this allows us to display each dealers inventory on a subdomain of the dealer’s domain name. We are one of the first companies to try to fully integrate a dealers inventory using HomeNet into WordPress(to the best of our knowledge).
If you visit Barnes Crossing Hyundai which is built in WordPress you will notice the inventory search function that we have built that is showing in the header(ours in the header is just a styled version of this: https://usedcars.bchyundai.com/bchyundaiv2/quicksearch-price.asp?type=used which if you click it, it works until rendered using a php iframe), if you just click search you will notice that the redirect in place will bring you to the subdomain (usedcars.bchyundai.com) and that is where our inventory pages are.
This dealer also has a Mazda dealership named Barnes Crossing Mazda which is a network blog in the same network as the Hyundai site so they are utilizing the same .htaccess file. Firstly, the inventory search function on the Mazda site is just going to the redirect set for Hyundai because it is the same slug (I need same slug to go to diff pages based on which domain they are on). So if you try to use the inventory search function in the header of the Mazda site you will end up on the Hyundai inventory pages due to this.
If I remove the redirects entirely the inventory search function will input the ending slug, but you end up on a 404 page because it will not go to the subdomain and will still show the www. instead of the intended subdomain usedcars.
These redirects are basically a hack and the true way to implement this would be using HomeNet’s API to build the inventory search and inventory display pages. We are not there yet, we are working on that and then we could scrap the backwebs entirely and display everything locally on pages spooled up by WordPress.
I could fix the issue for the time being by making each site its own WordPress installation but I really am trying to keep it all in one dashboard using a WP network because I just think this makes sense.
So to clearly answer your question after somewhat of an explanation behind all this, when I used the code mentioned in my last reply the inventory search function sent me to this url: https://www.bchyundai.com/browse/view_detailed/type_used/ when I really wanted it to send me here: https://usedcars.bchyundai.com/bchyundaiv2/browse/view_detailed/type_used/
(The url it sent me to is the same url that I get sent to when I remove the 301 redirects.)
Thank you for finding that, although this still did not work for me here is what I did:
RewriteEngine On RewriteCond %{HTTP_HOST} ^BCHYUNDAI.com [NC] RewriteRule ^(.*)$ https://www.BCHYUNDAI.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^www.bchyundai.com [NC] RewriteRule ^browse/view_detailed/type_used/\.aspx$ https://usedcars.bchyundai.com/bchyundaiv2/browse/view_detailed/type_used/ [R=301,NC,L] RewriteEngine On RewriteCond %{HTTP_HOST} ^BCMAZDA.com [NC] RewriteRule ^(.*)$ https://www.BCMAZDA.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^www.bcmazda.com [NC] RewriteRule ^browse/view_detailed/type_used/\.aspx$ https://usedcars.bcmazda.com/bcmazdav2/browse/view_detailed/type_used/ [R=301,NC,L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L] RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L] RewriteRule . index.php [L]
Now the interesting part is that I think this is somewhat closer to something that could work as the sites didn’t throw any kind of error after I uploaded this one, the redirect just didn’t go to the subdomain that we need it to go to. This is what I get for not going to school for web dev.
Thank you for your reply, although I tried this and it did not work. Here is what my code looked like after your suggestion:
RewriteEngine On RewriteCond %{HTTP_HOST} ^BCHYUNDAI.com [NC] RewriteRule ^(.*)$ https://www.BCHYUNDAI.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^(www\.)?bchyundai.com\.told [NC] RewriteRule ^browse/view_detailed/type_used/\.aspx$ https://usedcars.bchyundai.com/bchyundaiv2/browse/view_detailed/type_used/ [R=301,NC,L] RewriteEngine On RewriteCond %{HTTP_HOST} ^BCMAZDA.com [NC] RewriteRule ^(.*)$ https://www.BCMAZDA.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^(www\.)?bcmazda.com\.told [NC] RewriteRule ^browse/view_detailed/type_used/\.aspx$ https://usedcars.bcmazda.com/bcmazdav2/browse/view_detailed/type_used/ [R=301,NC,L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L] RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L] RewriteRule . index.php [L]
Thank you again for your help!