简体   繁体   中英

After a 301 redirect google finds strange urls

I have the following redirect in .htaccess:

Options -MultiViews

    RewriteBase /
    rewritecond %{THE_REQUEST} \s/+product\.php\?id=([^\s&]+)&name=([^\s&]+) [NC]
    rewriterule ^ %2/%1? [R=301,L]
    rewritecond %{REQUEST_FILENAME} !-d
    rewritecond %{REQUEST_FILENAME} !-f
    rewriterule ^([^/]+)/([^/]+)?$ /product.php?id=$2&name=$1 [L,QSA]

which works great. Also in place:

<base href="/" />

However on this page I have links to other pages which work ok when you click on them. They are defined like so:

<a href="http://www.mysite.co.uk/Roland-HPi50e-Digital-Piano-in-Rosewood/518">
<img src="/files/images/special_roland_hpi50e_160x500px.png" alt="Roland HPi Pianos">
</a>

The problem is - google doing something strange it is finding for example:

http://www.mysite.co.uk/a product/Roland-HPi50e-Digital-Piano-in-Rosewood/518

Is there anybody who can help me to sort this problem as I don't know what causes this. Any help welcome.

Might possible escape string problem, try this one, hope this will help you

RewriteEngine On
RewriteCond %{QUERY_STRING} ^out=([^&]+)
RewriteRule ^/?$ http://www.mysite.co.uk/Roland-HPi50e-Digital-Piano-in-Rosewood/518 [L,R=301]

Remove this tag:

<base href="/" />

For fixing images/css paths use absolute path in your css, js, images files rather than a relative one. Which means you have to make sure path of these files start either with http:// or a slash / .

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