How to make SEO friendly URL using .htaccess - .htaccess

I want to make this URL
https://www.maxelplus.com/single-commercial.php?PId=Mjc&Title=Domestic%20Products
to
https://www.maxelplus.com/domestic-products/table-top-wet-grinders/sleek-table-top-wet-grinder-2l-LEP883/
I used below code but is not working.
RewriteRule ^domestic-products/table-top-wet-grinders/sleek-table-top-wet-grinder-2l-LEP883/$ single-commercial.php?PId=$1&title=$2 [QSA]
Please share whate i am missing..

Depending on how your website is being hosted, it might be helpful to look at the .htaccess permalink structure which can be found here.
It looks like your first link is using a custom structure permalink, but your desired URL is a combination between post name and product number. A generic set of instructions can be found here if you are using WordPress. This can also clarify the benefits of using URLs that are friendly for Search Engine Optimization (SEO).

Related

Nginx URL rewrite to remove folder from URL when its followed by certain subfolders

After I have upgraded my site I see that once I go live with new version some parts of the website URLs will not be redirected for gallery, blogs and files because of new structure. And there is no way fixing it within the CMS. So my goal is to use NGINX redirects.
I wonder do any of you know any NGINX rewrite tricks to make such redirects possible?
website.com/forums/blogs/ into website.com/blogs/
website.com/forums/gallery/ into website.com/gallery/
website.com/forums/files/ into website.com/files/
I actually need the part forums dropped from the URL only and ONLY when the address is going for forums+blogs/gallery/files. Don't want to loose that google traffic.
So for example
website.com/forums/blogs/entry123/my-dog/ is redirected to
website.com/blogs/entry123/my-dog/
BUT
website.com/forums/topic/my-dog/
is left alone and working just like before because the following subfolder is neither blogs or gallery or files.
I needed that once on Apache and this one worked but on Nginx I have no idea.
RewriteRule ^forums/(blogs|gallery|files)/(.*)$ /$1/$2 [L,R=301]
You can try something like
rewrite ^/forums/(blogs|gallery|files)/(.*)$ /$1/$2;
Please note that rewrite directive accepts some flags wich meaning depends on where is it placed (is it inside a server or location block). Detailed documentation is here.

Joomla 2.5 - Adapting Custom URLs with .htaccess or tool

i've just finished a website with a database for golf-holidays. Now the clue is, i am using joomla internal url-rewrite to generate short urls which is generally great, i like it. The only thing left for SEO optimization would be, if i could point an individual URL to each offer listed in the database. A url to a specific offer looks like this :
http://www.mydomain.com/golfurlaub-mit-greenfee/angebote/urlaubsangebot.html?oid=128
"urlaubsangebot.html" would be the detail site, passed with the parameter "oid" for offerID and then the ID of the offer in my database.
Would it be possible to create a rule / use a tool where i would be agle to assign a custom URL to every offer? For example :
NewURL
http://www.mydomain.com/offers/spain/my-offer-name.html
OldURL
http://www.mydomain.com/golfurlaub-mit-greenfee/angebote/urlaubsangebot.html?oid=128
I tried using tools such as SEF404 and JoomSEF but they rather break my whole structure than help me apply these urls. Any ideas?
Joomla 1.6+ is shipped with Redirect Manager (Components > Redirect). It's designed exactly for this purpose (redirecting old urls to new ones).
Joomla 1.6 will include a new component and plugin called Redirect.
Its main function is to provide a mechanism to record 404 "not found"
errors, and to give the Web site owner the ability to redirect those
to another page if desired.
If there are links to your site that result in error 404, these should be already populated in the list when you open the manager - you just have to add new urls to which to redirect to.
References:
A preview of link redirection in Joomla 1.6
You can use the .htaccess rewrite rules for that:
RewriteEngine On
RewriteRule ^(offers/spain/my-offer-name.html)$ index.php?option=com_mycomponent&oid=128 [L]

Url duplication with Prestashop SEO

I have an e-commerce developed with the CMS Prestashop.
Yesterday i have seen in my Webmaster Tools that i had some duplicated URL, like this:
www.mysite.com/manufacturers
www.mysite.com/it/manufacturers.
Where 'it' is the suffix of the default and only language for the website.
I've already activate the friendly URL in the back-office and also I've a .htaccess file generated automatically by the generator in the back-office.
What should I do to fix this issue?
PS: Also I think that I've already taken a penalization from googlebot.
First of all let me clarify the Title from the SEO point of view. The problem is from Prestashop side not from SEO side. It is just affecting your SEO.
Now on the problem, Prestashop is notorious for URL problems. I would not recommend you the .htaccess hack solution because every time you regenerate your .htaccess from you backend, you have to manually insert that hack again in it to keep the problem down. And suppose this url problem arises again after sometime for some other url than you have to do it again. It can turn into a nightmare.
So here are some of my personal recommendations...
If this site is critical(which I am assuming), buy a Prestashop url rewriting module from a trusted provider. You will also get a technical support in case this problem arises again in future.
If you can't buy than I would suggest you to ask this question on Prestashop forums, as this is Prestashop specific, to permanently solve this problem. You will most likely to get more instant answers as you will find more people working on Prestashop there than here.
Somewhere either in the htaccess file in your document root, or in the vhost/server config for mysite.com, you'll need to 301 redirect. Now you just need to choose which one you want to keep, the one with /it/ in front or the one without? Let's say you want to point everything to the one without, you'll use one of these:
Using mod_alias:
Redirect 301 /it/manufacturers /manufacturers
Using mod_rewrite:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mysite.com$ [NC]
RewriteRule ^/?it/manufacturers(.*)$ /manufacturers$1 [L,R=301]

Symbol "?" in alias or Dirty url

I want to move the website to the Drupal CMS with original paths. It's look like
website.com/search.php?q=blablabla
website.com/index.php?q=blablabla
website.com/category.php?q=auto&page=2
etc
How can i use these aliases in Drupal? Thank you.
I think you will have great difficulty setting this up, if it's even possible. It would be much better to let Drupal use its standard clean URLs and to setup URL rewrite rules to translate requests for legacy URLs to the new ones.
For example, Drupal's search URL looks like:
website.com/search/node/blahblah
And in .htaccess you could define:
RewriteRule ^search.php\?q=(.*)$ /search/node/$1 [R=301,NC,L]
Which would match the format of your legacy search URL, extract the query and rewrite the URL so that query is in Drupal's clean form. That way requests to website.com/search.php?q=blah get translated to website.com/search/node/blah before getting sent to Drupal. The user however will see the new, Drupal-style URL.
mod_rewrite is well documented.
This is of course going to be harder to do if your legacy URLs make use of unique IDs that do not exist in Drupal. In that case I'd take care to make sure that node IDs and taxonomy IDs etc all correspond between your legacy site and your new site. That way you could translate something like /view.php?articleID=121 to /node/121.
This has the effect of handling any incoming links from search engines, third party sites, or users' bookmarks, but leaves you with an entirely new URL structure. I've used this approach before when migrating to Drupal.

Rewrite URL to remove first page pagination using htaccess

I have an paginated list of articles and my search engine is indexing the first page twice as /articles and /articles?start=1.
I want to write an .htaccess rewrite rule to rewrite any requests for /articles?start=1 to /articles to stop this from happening.
There are a couple of other article based paginated lists on the site, so i need to match just the parameter rather that the full url, so that the rule will work on thse urls also.
Thanks for your help!
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} \/articles\/
RewriteCond %{QUERY_STRING} start=1
RewriteRule (.*)$ /index.php\?
I am assuming articles is a directory.
A bit of a necro, but I just found this question via Google when looking for something else.
Recently, Google offered up way more control over how URL parameters affect their indexing of your site. Go to Google Webmaster Tools and set up your site.
Google will crawl your site and add a list of URL parameters its aware of (and I beleive you can add your own to the list). You can specify how the URL parameters affect your page (pagination, filtering, internal etc) which in turn tells Google how to index it.
In this case, you'll be able to say that start should be either ignored, indexed only once, or treated how you see fit to make sure it only appears how its meant to in the index.
This helps Google and also helps you, so its entirely win-win.

Resources