I'm having an issue with mod rewrite. eg: url: http://www.domain.com/result.php?url=google.com I want url to be accessible by either: http://www.domain.com/google.com or http://www.domain.com/google-com $5 via paypal for the first person with the fix
Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.[^/]*) /result.php?url=$1 [NC,L] PHP:
thanks MyVodaFone, but if http://www.domain.com/result.php?url=google.com is entered as a url it doesnt automatically change to http://www.domain.com/google.com can that be done?
As in the PM I just replyed to... you dont enter domain.com/result.php?url=google.com you enter domain.com/google.com Which means you need to change how you are writting your links: possible domain.com/<?echo $your-search;?>
This might need some tweeking: 1, create or add to folder /includes/ajax.js ajax.js var serverProtocol = (window.document.location.protocol ? window.document.location.protocol : 'http:'); var serverURI = (window.document.location.hostname ? serverProtocol+'//'+window.document.location.hostname : ''); function ajax(url,method,process_function){ var XMLHttpRequestObject = false; if ( window.XMLHttpRequest ){ XMLHttpRequestObject = new XMLHttpRequest(); } else if ( window.ActiveXObject ){ XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); } if( XMLHttpRequestObject ){ var data_source = url + '&_t=' + Math.random(); if (method=="POST") { XMLHttpRequestObject.open( "POST", data_source ); } else { XMLHttpRequestObject.open( "GET", data_source ); } XMLHttpRequestObject.onreadystatechange = function(){ if ( XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200 ){ var xmlDocument = XMLHttpRequestObject.responseXML; delete XMLHttpRequestObject; XMLHttpRequestObject = null; process_function(xmlDocument); } else { process_function(xmlDocument); } } XMLHttpRequestObject.send( null ); } } Code (markup): 2, write into your page head> section: <script src="/include/ajax.js" type="text/javascript" language="javascript"></script> PHP: 3, write to the body> section ( where your adding the form to submit ) <div id="overlay"></div> <script type="text/javascript"> function checkUrl(search_form) { url_check=document.search_form.domain.value.toLowerCase(); var url=url_check.split('.'); var final_letter=url_check.substring(url_check.length-1,url_check.length) if(final_letter=='.') {alert("Please type a valid url"); return false;} if(url_check=='www.') {alert("Please type a valid url"); return false;} else if(url_check.split('/').length>1){alert("Please type a valid url"); return false;} else if(url_check.split(' ').length>1){alert("Please type a valid url"); return false;} else if(url.length<2) {alert("Please type a valid url"); return false;} else if(url[0]=='www' && url[1]=='www') {alert("Please type a valid url"); return false;} else { document.getElementById('overlay').style.display='block'; if(url[0]!='www') searchurl(serverURI+'/www.'+url_check+'/'); else searchurl(serverURI+'/'+url_check+'/'); } return false; } function searchurl(url) { ajax(url+'?ajax=1','GET',function(){setTimeout('window.location="'+url+'"',1000)}); } </script> <form name="search_form" action="/" onsubmit="checkUrl(search_form); return false;"> <input name="domain" value="www." type="text"> <input value="Check" type="submit"> </form> PHP: If your still having problems with results.php feel free to PM me for a solution EDIT your new .htaccess will be something like this ( not tested ) Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule www.(.*)\.(.*) /result.php?url=$1 [NC,L] RewriteRule (.*)\.(.*) /result.php?url=$1 [NC,L] PHP: