...

View Full Version : .htaccess help



cosmicsea
11-03-2010, 10:26 AM
I am trying to make my search engine links more search engine friendly and I have tried so many different thing with .htaccess but cannot quite get it to work.
here is what my url looks like
http://domain.com/search.php?query=keyword&search=1

here is what I have been trying. This is the best results I have gotten so far.



Options -Indexes
Options +FollowSymLinks

RewriteEngine on
RewriteCond %{QUERY_STRING} ^query=(.*)\&search=1$

RewriteRule ^search\.php$ /search/%1/? [R=301,L]

RewriteRule ^search/(.*) search\.php\?query=$1\&search=1 [L]

when i do a search for the word keyword it looks like this http://domain.com/search/keyword/ but it doesn't show anything. i can see that it is picking up the keyword but i dont quite understand why this doesn't work. Can anyone help?

cosmicsea
11-03-2010, 10:44 AM
I think what is going on is &search=1 is not picking up. I cant seem to get it to grab that part of the link or something.

cosmicsea
11-03-2010, 01:24 PM
Any help is appreciated. I kep trying different stuff and that same code is where I always end up. is there something I can do so that I dont have to manually change the php code that creates the urls? mod_rewrite just does not want to work right with this.

ax8l
11-03-2010, 02:10 PM
RewriteRule ^search.php$ /search/%1/? [R=301,L]

RewriteRule ^search/(.*) search.php?query=$1&search=1 [L]

are making a loop
search.php rewrites to /search/* which rewrites to search.php which rewrites to /search/* etc
I would introduce a ReWriteCond %{REQUEST_URI} !^search\.php$ or something like that.
Actually i think you can't really filter the search.php because that will skip the whole rewrite.
Maybe something in the vicinity of

RewriteRule ^search/(.*)(/)?$ search.php?query=$1&search=1 [L]
ReWriteCond %{REQUEST_URI} ^search\.php$
RewriteRule ^search.php?query=(.+)&search=1$ http://www.url.com/search/%1/? [R=301,L]

I have not tested this code, it's written from the top of my head..
I hope it helps you.. somehow

cosmicsea
11-04-2010, 12:51 AM
RewriteRule ^search.php$ /search/%1/? [R=301,L]

RewriteRule ^search/(.*) search.php?query=$1&search=1 [L]

are making a loop
search.php rewrites to /search/* which rewrites to search.php which rewrites to /search/* etc
I would introduce a ReWriteCond %{REQUEST_URI} !^search\.php$ or something like that.
Actually i think you can't really filter the search.php because that will skip the whole rewrite.
Maybe something in the vicinity of

RewriteRule ^search/(.*)(/)?$ search.php?query=$1&search=1 [L]
ReWriteCond %{REQUEST_URI} ^search\.php$
RewriteRule ^search.php?query=(.+)&search=1$ http://www.url.com/search/%1/? [R=301,L]

I have not tested this code, it's written from the top of my head..
I hope it helps you.. somehow

no that doesnt work either, even after i messed with it. I am still trying to make something work. I made a mod_write log so i know what is going on each query but i am still having trouble.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum