简体   繁体   中英

URL Rewrite - Not from .htaccess - Magento

Looking for a bit of help as ending up going round in circles trying to understand where the problem may lie.

We recently had our magento side on www.domain.com which would shop through rewrite rules as: "domain.com/"

This was correct.

However, as we are targeting the UK market, the site being relatively new we decided to buy up the .co.uk domain and make the switch. Making it www.domain.co.uk, this was all changed correctly in the magento database/backend yet this now starts showing: "domain.co.uk"

Missing the forward slash on the end.

I have confirmed in the mysql database that the URL has a slash, and have even turned off mod_rewrite from the .htacess, yet there is still a rewrite occurring from somewhere.

It seems like forever since I set this up on the previous site to remove the "http://" and add the forward slash, but I can't remember how or where I set this.

If anyone could point me in the right direction that would be greatly appreciated.

Kind Regards

Edit : Below is the code for rewrite:

<IfModule mod_rewrite.c>

############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on

############################################
## you can put here your magento root folder
## path relative to web root

    RewriteBase /

############################################
## uncomment next line to enable light API calls processing

#    RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]

############################################
## rewrite API2 calls to api.php (by now it is REST only)

    RewriteRule ^api/rest api.php?type=rest [QSA,L]

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]

############################################
## redirect for mobile user agents

    #RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
    #RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
    #RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links


    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]

</IfModule>

make sure you update all instances of the web/unsecure/base_url & web/secure/base_url in the core_config_data table, I'd suggest searching this table for all values like %domain.co.uk%. Also delete the cache folder as some config values aren't completely removed with the admin Clear cache button.

Are you sure there is an actual redirect happening? Try using this site http://redirectcheck.com to see if you are actually being redirected. Some browsers will not show the http:// or trailing / so it may not be an actual issue.

If you need to redirect non-www to www add the following lines to your .htaccess file below " RewriteEngine on"

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM