htaccess mod_rewrite for Opencart search page URLs - .htaccess

I'm having some difficulty creating an htaccess mod_rewrite rule which would take the following URL:
http://www.mydomain.com/index.php?route=product/search&filter_name=SEARCH%20CRITERIA
and make it something more along the lines of:
http://www.mydomain.com/search/SEARCH-CRITERIA
or even
http://www.mydomain.com/search?filter_name=SEARCH%20CRITERIA
Everything I've tried seems to break the SEO-friendly URLs that are auto-generated by the Opencart framework. How can this be done?

In Your .htaccess file place the rules directly behind the lines used to rewrite sitemap.xml and googlebase.xml and before the last general rule.
The rule could look like:
RewriteRule ^search\/(.*)$ index.php?route=product/search&filter_name=$1
- did not test it, it is just a guess.
Also showing us what have You tried would be highly appreciated.

Related

how to rewrite SEO friendly url in htaccess

How to create an SEO friendly URL like example.com/pages/my-first-page/followers here I want how to create a structure in if(isset($_GET['followers'])){...} and htaccess file.
My link working fine till example.com/pages/my-first-page/ but now I want to add followers section.
I hope i explain well what I expecting. Thanks for your help
Rule you've suggested is this:
RewriteRule ^pages/([\w-]+)/followers/?$ page.php?pages=$1&followers=1 [QSA,NC,L]
This is pretty good rule and there is no reason why it should not work. Make sure this rule is placed before page rule which is your first rule in .htaccess

htaccess URL overwrite - Magento

I have some URLs that I would need to overwrite so that if someone looks at the source code they can't actually see the real URLs for the product images in Magento. Currently, the link is as
externalsub.domain.com/images/image123.jpg
I want to make it as
mydomain.com/images/image123.jpg
How can I achieve this via .htaccess? Any help is much appreciated!
Then in an htaccess file, you can use this (above whatever rules you may already have):
RewriteEngine On
RewriteRule ^images/([^/]+\.(?:jpe?g|png|gif))$ http://externalsub.domain.com/images/$1 [L,P]
You don't need the line turning on the rewrite engine if you already have that (only needs to be in your file once).

How to redirect a folder and its pages to a single page

I'm trying to redirect some files and I'm pretty stuck. There are way too many to do some of them on a "page-per-page" basis and so I need a quick way as these pages are insignificant but return 404's at the moment.
I have a page like this "/old-blog/tag/page", I previously redirected the "old-blog" to "new-blog" so I get "/new-blog/tag/page" but now I want "tag" and all pages after this to be sent to "new-blog". I hope this example makes sense, please ask if I've missed something.
I'm doing my redirects with my .htaccess file so I'd like a method I can use with this in mind.
Thanks, Dan.
You may already have rewrite rules, if there are rules that do some type of routing, then mod_rewrite and mod_alias is going to conflict (RedirectMatch is mod_alias). So try sticking with just mod_rewrite. Try adding these rules, above any other rules, in the htaccess file in your document root:
RewriteEngine On
RewriteRule ^/?old-blog/tag /new-blog/ [L,R=301]

.htaccess rewrite rule from mydomain.com/contact.htm to mydomain.com/contact

I guess this was a very common and simple .htaccess rewrite rule, however I wasn't able to google a solution for it.
So, the question is in the title already, how can I rewrite the address to change it from example.com/contact.htm to example.com/contact? The rule would of course not be only for just the contact.htm but for any page in the website. No need to worry about GET variables, since I won't be using any.
[ Also, do you think this is or might be considered a good practice or not really relevant? ]
Thanks.
Try this:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^contact.htm$ /contact
This should serve contact.html when requesting example.com/contact/
You could consider using MultiViews. You'll need to load the content negotiation module and turn MultiViews on, then Apache will automatically look for a file with an extension (there's a priority list in case you have both .html and .htm files with the same name for instance).

using mod_rewrite to create SEO friendly URLS

I've been searching google for this but can't find the solution to my exact needs. Basically I've already got my URL's named how I like them i.e. "http://mysite.com/blog/page1.php"
What I'm trying to achieve (if it's possible!) is to use rewrite to alter the existing URLS to: "http://mysite.com/blog/page1"
The problem I've come across is I've found examples that will do this if the user enters "http://mysite.com/blog/page1" into the broweser which is great, however I need it to work for the existing links in google as not to loose traffic, so incoming URLS "http://mysite.com/blog/page1.php" are directed to "http://mysite.com/blog/page1".
The 1st example (Canonical URLs) at the following is pretty much what you want:
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html#url
This should do the trick, rewriting requests without .php to have it, invisible to the user.
RewriteEngine On
RewriteRule ^/blog/([^.]+)$ /blog/$1.php
You will need to write a rewrite rule for mapping your old url's to your new url as a permanent redirect. This will let the search engine know that the new, seo friendly url's are the ones to be used.
RewriteRule blog/page1.php blog/page1 [R=301,L]

Resources