Search code examples
php.htaccessgoogle-index

htaccess - how to rewrite rule for lower and uppercase urls


i have following .htaccess, i am getting double urls in google....i have tried some codes in order to block uppercase urls....but nothing works for me...

example of double urls

/Come.php
/come.php

my htaccess file

RewriteEngine On

RewriteRule ^my/shop/([a-zA-Z0-9-]+)/?$ /my/shop/shop.php?cid=$1 [L,QSA]
RewriteRule ^my/brand/([a-zA-Z0-9-]+)/?$ /my/brand/brand.php?cid=$1 [L,QSA]
RewriteRule ^my/social-share/([a-zA-Z0-9-]+)/?$ /my/social-share/share.php?shareid=$1

ErrorDocument 404 http://www.myweb.co.uk/404.php

i have no idea how to block uppercase urls..

thanks for your help.


Solution

  • You could try:

    RewriteEngine On
    
    RewriteRule ^my/shop/([a-z0-9-]+)/?$ /my/shop/shop.php?cid=$1 [L,QSA]
    RewriteRule ^my/brand/([a-z0-9-]+)/?$ /my/brand/brand.php?cid=$1 [L,QSA]
    RewriteRule ^my/social-share/([a-z0-9-]+)/?$ /my/social-share/share.php?shareid=$1
    
    ErrorDocument 404 http://www.myweb.co.uk/404.php
    

    Just remove the A-Z in each query...Then the regex won't match on it.