Portal Home > Knowledgebase > Articles Database > Need some mod_rewrite help
Need some mod_rewrite help
Posted by Arber, 02-27-2010, 12:28 PM |
So I am working on a little script & I am doing some mod_rewrite and I need some help
RewriteCond %{REQUEST_URI} /index.php$
RewriteCond %{QUERY_STRING} ^search=([A-Za-z0-9\+]+)$
RewriteRule ^(.*)$ /search/1/%1\.html [R=301,L]
RewriteRule ^search/([^/]*)/([^/]*)\.html$ /index.php?page=$1&search=$2 [L]
I have that but when I search it does
http://www.MYDOMAIN.com/search/1/MYS...earch=MYSEARCH
how do I remove the ?search=MYSEARCH
|
Posted by angathan, 02-27-2010, 11:14 PM |
Hi,
Just try changing the rewrite rule
RewriteRule ^(.*)$ /search/1/%1\.html [R=301,L]
Specify the file or location istead of ^(.*)$
|
Posted by mattle, 03-01-2010, 09:00 AM |
This seems troublesome to me...
1. Do you really want to match everything that ends with '/index.php' (that would include '/index.php', '/foo/index.php', '/bar/index.php'...)
2. If I'm not mistaken the URI will also include the query string, so this condition only matches if there is not one and the next condition only matches if there is one! Maybe I'm wrong about this, if you are getting matches, however.
Either way, I agree with angathon, instead of using rewrite conditions to look at parts of the URI, just use a specific regex in your rewrite rule:
|
Posted by HivelocityDD, 03-03-2010, 01:30 PM |
Is this you are looking for ?
|
Add to Favourites Print this Article
Also Read