Reputation: 11
Please help me. How can I do for www.example.com/search.php?q=skipsoft to www.example.com/skipsoft?
Upvotes: 0
Views: 157
Reputation: 18185
If you want to redirect everything you can do something like this in your .htaccess
file if you're using apache:
RewriteEngine On
RewriteRule ^(.*)$ /search.php?q=$1 [L,R]
But I would recommend something like this:
RewriteEngine On
RewriteRule ^/s/(.*)$ /search.php?q=$1 [L,R]
This will match www.yourdomain.com/s/author to www.yourdomain.com/search.php?q=author.
Upvotes: 1
Reputation: 19551
Without using JavaScript (which is a bad idea to modify the essential parts of a website, e.g. search), you won't be able to make forms submit data to a page that's not in the form /pagename?q=query or w/e.
But if you'd just like to shave of the .php extension, this will do the trick:
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
In your .htaccess file, this will make it so that any file with a .php extension can be accessed without one.
Upvotes: 0