Chat Room Article Base Facebook Page Twitter RSS Feed
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 24, 2012, 12:05:23 PM

Login with username, password and session length
Search:     Advanced search
The E-commerce forum, the best place for advice for your Small Business.
12794 Posts in 1521 Topics by 6461 Members
Latest Member: egrovesystems
* Home Help Search Login Register
+  E-commerce forum
|-+  E-commerce
| |-+  Website development
| | |-+  is this possible with htaccess
« previous next »
Pages: [1] Print
Author Topic: is this possible with htaccess  (Read 468 times)
JhnStcks
Global Moderator
Part of the Furniture
*****

Karma: 12
Offline Offline

Gender: Male
Posts: 419


WWW
« on: October 19, 2010, 02:33:39 PM »

Unknown to myself I have been getting errors with an installed module on Prestashop and it has been redirecting urls from http://www.mydomain.com/myproductid_blah_blah.php to http://www.mydomain.com/www.mydomain.com/myproductid_blah_blah.php.  Notice the duplicate domain name.

Was wondering if its possible to do some kind of wildcard redirect using htaccess to remove the duplicate second domain?
Logged

Empower Your Prestashop The home for Prestashop resources on Facebook. Modules, themes, hacks, hints and tips to empower your Prestashop site and make it stand out from the crowd.
seamus
zen master
Shareholder ;o)
*****

Karma: 44
Offline Offline

Gender: Male
Posts: 1109



WWW
« Reply #1 on: October 19, 2010, 02:59:41 PM »

if you treat the extra domain as a sub directory you can redirect it that way

Code:
RewriteRule ^www.mydomain.com(.*)$ http://www.mydomain.com$1 [L,R=301]

that bit of code would normally be used to redirect from a subdirectory to the root, eg if you wanted to redirect people from mydomain.com/shop/ to mydomain.com you would do this

Code:
RewriteRule ^shop(.*)$ http://www.mydomain.com$1 [L,R=301]

as far as the htaccess code is concerned the extra domain can be viewed as a subdirectory, even though it isnt, its just an error, using that code should return the browser to the right place though and forward you from mydomain.com/www.mydomain.com/products back to mydomain.com/products

I'd have a look through the plugin files though and see if you can spot the problem in there aswell, the htaccess rule should work though  thumbs up
Logged

scotserve
Guru
Shareholder ;o)
*****

Karma: 36
Offline Offline

Gender: Male
Posts: 820



WWW
« Reply #2 on: October 19, 2010, 07:10:50 PM »

Sorry John

meant to get back to you on this
I think? part of the problem is I think is the fact you have add on domains added to the public_html directory - we always suggest that addon domains are rooted above public_html, .htaccess acts at the root level and you have some very complex redirects in the file already
Logged

Scotserve - Premium Domain and Hosting services since 1994
JhnStcks
Global Moderator
Part of the Furniture
*****

Karma: 12
Offline Offline

Gender: Male
Posts: 419


WWW
« Reply #3 on: October 19, 2010, 10:36:47 PM »

I think you both misunderstood my question

My module was causing an error when it was redirecting to the friendly url, this has now been fixed by the module author releasing a fix.  But search engines have clawed the url that was created in error which is http://www.mydomain.com/www.mydomain.com.  I wanted to create a redirect to stop the error url., so people who visit the incorrect url will be redirected to the correct page.
Logged

Empower Your Prestashop The home for Prestashop resources on Facebook. Modules, themes, hacks, hints and tips to empower your Prestashop site and make it stand out from the crowd.
seamus
zen master
Shareholder ;o)
*****

Karma: 44
Offline Offline

Gender: Male
Posts: 1109



WWW
« Reply #4 on: October 19, 2010, 11:17:58 PM »

yip, that bit of code of mine does exactly that  great

Code:
RewriteRule ^www.mydomain.com(.*)$ http://www.mydomain.com$1 [L,R=301]

that would forward mydomain.com/www.mydomain.com/products to mydomain.com/products it would effectively remove the extra domain thats there in error from any url that has it in it
so if someone tried to go to
http://www.mydomain.com/www.mydomain.com/products
they would be forwarded to
http://www.mydomain.com/products

it would work on any url that had the duplication in it and effectively remove the duplication

basically that bit of code as I said is designed to redirect people from one subdirectory to the root or to another subdirectory but it will work fine to sort the problem of the duplicate domain name in the url
http://www.mydomain.com/www.mydomain.com/
a browser will try to find a subdirectory called www.mydomain.com using that link above, even though its just an error and the domain name has been produced twice, using the code that is designed to redirect people from one subdirectory to another will do the job you want and basically remove the duplicated domain name in the url

honestly John, it will sort the problem your talking about  8)
« Last Edit: October 19, 2010, 11:35:09 PM by seamus » Logged

JhnStcks
Global Moderator
Part of the Furniture
*****

Karma: 12
Offline Offline

Gender: Male
Posts: 419


WWW
« Reply #5 on: October 19, 2010, 11:34:50 PM »

Excellent thanks Seamus, works perfectly.  Hopefull will only need it for a month or so till the search engines update the links.

Have some Karma, on me
Logged

Empower Your Prestashop The home for Prestashop resources on Facebook. Modules, themes, hacks, hints and tips to empower your Prestashop site and make it stand out from the crowd.
seamus
zen master
Shareholder ;o)
*****

Karma: 44
Offline Offline

Gender: Male
Posts: 1109



WWW
« Reply #6 on: October 19, 2010, 11:35:56 PM »

cheers John  great

ye should thank paul010 aswell, I ran it by him before I posted lol
Logged

Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
SimplePortal 2.2.2 © 2008-2009