Hi all just a quick question, How is this website do this as I have been looking a the URL EG hXXp://www.nextag.com/testbox And it passes anything after the domain name as the search criteria without using a “ ? “ I can only imaging it could be a .htacccess file doing the process but how?
What would the coding look like i have seen something like you can pass $1 ect when you rewrite the url but how would that pass to the another url
Lets say the search term is "search" and the value is "widget". The search page might redirect to www.domain.com/search/widget and the MOD rewrite would change the URL to www.domain.com/index.php?search=widget but of course you wouldn't see this. You just need to point the search to a handler which will redirect the page such as ; <?php header('Location: http://www.domain.com/search/' . $_POST['search']); ?> PHP:
Exmaple of .htaccess RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.+?)$ /search.php?what=$1 [L,QSA] Code (markup): Where RewriteCond %{REQUEST_FILENAME} !-f will not rewrite queries to search.php and rewrite queries like http://site.com/elephant to http://site.com/search.php?what=elephant And in PHP you can access value like this $what_to_search = $_GET['what']; PHP:
still getting a 500 error RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.+?)$ /search.php?what=$1 [L,QSA] the file is a folder called /jump
I've just tested it - it works on my hosting. Maybe you don't have mod_rewrite or it is configured in another way. For example http://mysite.com/lalala <? print_r($_GET); ?> PHP: outputs Array ( [what] => lalala ) Code (markup):
To find out if your server has mod rewrite installed create a file called "php.php" and insert the following into it; <?php phpinfo(); ?> Search the page for "mod_rewrite" and it should be listed in the category "Loaded Modules". Mod rewrite comes with Apache but can sometimes not be turned on but it's not too difficult to sort this out if it is the case.