I am developing a web app in which name of other website are supposed to be given as parameters, am rewriting urls using .htaccess file on my apache web server, this is the code i wrote in my .htaccess file:
RewriteEngine On
RewriteRule ^([a-z0-9\_\-]+(\.)[a-z0-9\_\.\-]+)[^(site.php)] site.php?url=$1
RewriteRule ^([a-z0-9\_\-]+(\.)[a-z0-9\_\.\-]+)[^(site.php)]/ site.php?url=$1
I wrote [^(site.php)] this because it was passing site.php as parameter as site.php was a match for my regex. This is working the right way but the only problem is that the last character of the parameter is omitted, for example, when am writting:
www.mywebsite.com/google.com
its taking google.co and omitting the last m. If am passing google.co.in, its taking google.co.i and omitting the n. What can be the reason for this?
Since you use
[^(site.php)](and it doesn’t means what you think), it will match the last character of your url. You should use a RewriteCond, you can try :Wich means : do not rewrite for existing file or directory