rerwrite url in .htaccess - .htaccess

I want to make the old urls point to the new pages. I'm having trouble because the old URL looks like this: http://nilandsplace.com/store/camping_eng/coghlans-campfire-cooking-forks-toaster-forks-package-of-4.html.
I want to do a URL re-right in .ht access from mywebsite.com/camping_eng/some.html to mywebsite.com/camping/some.html, were the "some.html" part is identical.
Only camping_eng changes to camping.

You might want to try this:
RewriteEngine on
RewriteRule ^camping_eng/([a-zA-Z0-9-=_.]+)/?$ http://mywebsite.com/camping/$1 [L,R=301]
This example works according to your question:
from mywebsite.com/camping_eng/some.html
to mywebsite.com/camping/some.html were the "some.html" part is identical.

RewriteEngine on
RewriteBase /store
RewriteRule ^camping_eng/(.*)$ camping/$1 [QSA,L,R=301]

Related

htaccess to remove part of a url, .htaccess

I was wondering how it is possible to remove part of a url with htaccess for example I have a url like this:
http://localhost/item.php?pa=gd34392
now I need to use htaccess to redirect this page or anything like this to a page with this url:
http://localhost/gd34392
I have tried things like this but nothing seems to work and I do not really know my way around htaccess
RewriteEngine on
RewriteRule item.php?pa=$1 /$1 [R=301,L]
You can achieve that using the following rules in your .htaccess:
RewriteEngine On
RewriteRule ^([^/]*)$ /item.php?pa=$1 [L]
Just make sure you clear your cache before testing this.

Transform(redirect) URL segment to a GET parameter

I know this has probably been answered but I can't find anything specific to my issue.
I have URLS like this:
https://staging.books.co.za/travelguide/route-map/SAFI546754
https://staging.books.co.za/travelguide/route-map/SAFI189444
https://staging.books.co.za/travelguide/route-map/SAFI978634
and I need them to be redirected to URLS like this:
https://staging.books.co.za/travelguide/route-map?reference=SAFI546754
https://staging.books.co.za/travelguide/route-map?reference=SAFI189444
https://staging.books.co.za/travelguide/route-map?reference=SAFI978634
Please help...What would the rule look like in my .htaccess file???
This should do the trick:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^travelguide/route-map/(.+) /travelguide/route-map?reference=$1
See here for a demo http://htaccess.mwl.be?share=6c2be57a-6bb7-5083-9122-aaf63162b240
Try and use this in your .htaccess:
RewriteEngine On
RewriteRule ^travelguide/route-map/([-a-zA-Z0-9_]+)/?$ route-map?reference=$1 [L]
Make sure you clear your cache before testing this.

URL Rewrite is not working correctly in .htaccess

I am trying to create a rewrite in my .htaccess file for my wordpress site. I need
www.a3performance.com/fastestsuit
to point to
http://www.a3performance.com/legend-fastest-racing-suit/
I am trying this, but it doesn't seem to work?
RewriteRule ^fastestsuit/?$ legend-fastest-racing-suit [NC,L]
Seems that you need to use here Redirect from one folder to new folder.
Something like this:
RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L]
Actually #labris idea worked. For some reason it took a bit for my server to register the .htaccess change.
RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L]

.htaccess - Redirect all .html capture the ID

I am facing the following problem:
I have a website in which the URLS currently look like:
/manufacturer/product/[ID].html
I have re-developed the website (Using Laravel) and now it just is:
/product/[ID]
I am wondering whether it is possible to use a .htaccess file to redirect all these links back to the new link? So, in essence, I would need to just capture the [ID] from the old link and redirect it back to the new link.
EDIT:
So the link will look something like this:
mysite.com/parts/apple/A-6-H0.htm
OR
mysite.com/microsoft/A-1-5F.htm
So both Apple, Microsoft and A- can change depending on what manufacturer and what the product is Does this make sense?
RewriteEngine On
RewriteRule ^parts/(?:[^/]+/)?(.*)\.html?$ /parts/$1/ [R=301,L]
That should take care of it.
Please Try this:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^{domain name}[nc]
RewriteRule ^(.*)$ {domain name}/$1 [r=301,nc]
Redirect 301 /manufacturer/product/$1.html product/$1.html

How do i URL rewrite using .htacess

i need some help rewriting URL using .htaccess my urls looks like:
http://www.example.com/testro2/product.php?id=426834&productStore=396
And i need have it work with text into it, example:
http://www.example.com/testro2/product/{anythinghere}/id=4268334&productStore=369
or you can make it look more clear like removing id= and &productStore= will be great, else i can use with them. example
http://www.example.com/testro2/product/{anythinghere}/4268334/396
The thing is that i need to have my keyword anythinghere in the URL.
Also, i would like to rewrite
http://www.example.com/testro2/search.php?q=shoes
TO
http://www.example.com/testro2/search/shoes
You can put this code in your /testro2/.htaccess
RewriteEngine On
RewriteBase /testro2/
RewriteRule ^product/.+/(\d+)/(\d+)$ product.php?id=$1&productStore=$2 [L]
RewriteRule ^search/(.+)$ search.php?q=$1 [L]

Resources