Scott
Scott

Reputation: 53

.htaccess going to the wrong file, queries are being lost

Basically I had my website on another server originally and all the .htaccess worked fine - We then transferred the server to our new server and the phpinfo() commands runs almost the exact same settings.

We have a url structure like this for example;

http://example.org/tag/example+tag

and we have the same sort of structure for our search for example;

http://exampe.org/search?search=search+term

However, for some mad crazy reason when you go to the tag url it's going to the search page.. Here is our .htaccess;

Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteRule ^sitemap.xml sitemap.php
RewriteRule ^login login.php
RewriteRule ^register register.php
RewriteRule ^dashboard dashboard.php
RewriteRule ^addserver addserver.php
RewriteRule ^tag/([^/]+)/?$ searchtag.php?tag=$1 [NC,L]
RewriteRule ^search search.php
RewriteRule ^ad/(.*)$ cron_servers_banners.php?server=$1 [L,QSA]
RewriteRule ^list/([a-zA-Z0-9\-]+) list.php?page=$1 
RewriteRule ^edit/(.*)$ serveredit.php?sid=$1 [L,QSA]
RewriteRule ^server/(.*)$ serverpage.php?sid=$1 [L,QSA]
RewriteRule ^server/(.*)/remove$ serverpage.php?sid=$1&remove=yes [L,QSA]
RewriteRule ^server/(.*)/cremove$ serverpage.php?sid=$1&cremove=yes [L,QSA]
RewriteRule ^server/(.*)/favourite$ serverpage.php?sid=$1&favourite=yes [L,QSA]
RewriteRule ^server/(.*)/unfavourite$ serverpage.php?sid=$1&unfavourite=yes [L,QSA]
RewriteRule ^sponsor/(.*)$ sponsor.php?sid=$1 [L,QSA]
RewriteRule ^history/(.*)$ serverhistory.php?sid=$1 [L,QSA]
RewriteRule ^vote/(.*)$ servervote.php?sid=$1 [L,QSA]
RewriteRule ^lost lost.php
RewriteRule ^logout logout.php

Upvotes: 1

Views: 55

Answers (1)

Ohgodwhy
Ohgodwhy

Reputation: 50767

Essentially, you're redirecting /tag/sometag to searchtag.php?tag=sometag.

RewriteRule ^tag/([^/]+)/?$ searchtag.php?tag=$1 [NC,L]

However, you have another existing rule that says, "match anything that starts with search"

RewriteRule ^search search.php

Because search is part of searchtag you must add a trailing /.

RewriteRule ^search/ search.php

Upvotes: 3

Related Questions