How Can i convert url ????
my current url
http://www.marketresearchandstatistics.com/report/ad/carbon-nanotubes-cnt-market-analysis-by-product-single-walled-carbon-nanotubes-swcnt-multi-walled-carbon-nanotubes-mwcnt-by-application-polymers-energy-electrical-electronics-and-segme/
and
It's convert TO using htaccess
http://www.marketresearchandstatistics.com/report/carbon-nanotubes-cnt-market-analysis-by-product-single-walled-carbon-nanotubes-swcnt-multi-walled-carbon-nanotubes-mwcnt-by-application-polymers-energy-electrical-electronics-and-segme/
To redirect /report/dir/foobar to /report/foobar , you can use the following redirect :
Redirect 301 /report/dir/ /report/
Related
I have to manually redirect few URLs in my website1 to website2.
Below is my code in the .htaccess file of website1
Redirect 301 /post1/ https://www.website2.com/post1
When I enter https://www.website1.com/post1/ in the browser it's being redirected to https://www.website2.com/post1 successfully, as expected.
But, When I enter https://www.website1.com/post1 in the browser it's being redirected to https://www.website2.compost1, the slash is missing after https://www.website2.com
What could be done to solve this?
You can do this in a single rule using RedirectMatch that uses a regex to make trailing slash optional as this:
RedirectMatch 301 ^/(post1)/?$ https://www.website2.com/$1
Added benefit is avoiding repeat of post1 in source and target by using a capture group in source and using back-reference $1 in target.
Remove the trailing / from the Redirect.
Redirect 301 /post1 https://www.website2.com/post1
This redirect then works for both versions of the URL. See testing link here.
Using 2 Redirect URLs in this particular order solved it.
Redirect 301 /post1 https://www.website2.com/post1
Redirect 301 /post1/ https://www.website2.com/post1
How can I go about redirecting all instances of a URL that containt -2.html with just .html?
So for instance I would want www.url.com/slug-2.html to redirect to www.url.com/slug.html
You can use the following Redirect :
RedirectMatch ^/([^-]+)-2\.html$ http://url.com/$1.html
So I want to redirect
domain2.com/path/url to a different domain, domain1.com/pathDurl where the / is replaced by a D or other character?
Is this possible?
You can use the following redirect in /domain2/.htaccess :
RedirectMatch 302 ^/path/(.+)$ http://domain1.com/pathD$1
This will redirect :
http://domain2.com/path/foobar
to
http://domain1.com/pathDfoobar
I want to redirect all of products from oldsite to corresponding newsite as follows using htaccess.
if input is : oldsite.com/prod1.html
then output should be : newsite.com/products.asp?code=prod1
if input is : oldsite.com/prod2.html
then output should be : newsite.com/products.asp?code=prod2
and same to prod3,prod4 and so on.
Try the following mod_alias based solution:
RedirectMatch 302 ^/httpdocs/([^.]+)\.html$ http://newsite.com/products.asp?prod=$1
this will redirect
http://example.com/prod0-9.html
to
http://example.com/products.asp?code=prod0-9
I'm in need to have redirect instruction to redirect the old URL with query string to new URL without query string. And the new URL depends on value of query string. For example:
I want:
http:// www.mydomain.com/product.php?id_product=AAA
Will redirect to:
http:// www.mydomain.com/product-name-for-product-number-1
And
http:// www.mydomain.com/product.php?id_product=BBB
Will redirect to:
http:// www.mydomain.com/this-is-different-product-name-for-product-number-2
Thanks in advance.
you can do this type of redirection:
from: http:// www.mydomain.com/product-name-for-product-number-AAA
to: http:// www.mydomain.com/product.php?id_product=AAA&name_product=product-name
from: http:// www.mydomain.com/this-is-different-product-name-for-product-number-2
to: http:// www.mydomain.com/product.php?id_product=BBB&name_product=this-is-different-product-name
you cannot retrieve dinamically the product name from htaccess file, the only method to do this is:
RewriteRule ^(.+)-for-product-number-(.+)$ ^product.php?id_product=$2&name_product=$1
or you need to create a rewriterule for each product you have (you can generate the .htaccess from a script that retrieve from db all products id & name):
RewriteRule ^product-name-for-product-number-1$ product.php?id_product=AAA
RewriteRule ^this-is-different-product-name-for-product-number-2$ product.php?id_product=BBB
It seems to me you cannot perform a redirection based on a query string. So you would have to add [QSA] flag and redirect to a script which will be able to redirect thanks to the query string.