im kind a new in this mod rewrite thing.
im trying to do some basic redirect.
Options +FollowSymLinks
RewriteEngine on
ErrorDocument 404 /index.php
RewriteCond %{HTTP_HOST} ^pickndrive.info
RewriteRule (.*) http://www.pickndrive.info/$1 [R=301,L]
RewriteRule ^new/cars/([^/]+)/([^/]+)/? profiles.php?carname=$2&carnumb=$1 [L]
RewriteRule ^used/cars/([^/]+)/([^/]+)/? used.php?carname=$2&carnumb=$1 [L]
RewriteRule ^compare/([^/]+)/([^/]+)/([^/]+)/? compare.php?car[]=$1&car[]=$2&car[]=$3 [L]
RewriteRule ^compare/([^/]+)/([^/]+)/? compare.php?car[]=$1&car[]=$2 [L]
RewriteRule ^compare/([^/]+)/? compare.php?car[]=$1 [L]
thats my .htaccess but its in a very bad condition !
what im trying to do is.
1) Trying to tell google that pickndrive.info and http://www.pickndrive.info are the same.
2) redirect /new(or used)/cars/(INT value)/(string) to X.php?carname=(string)&carnumb=(INT)
3) redirecting /cars/(STRING) into a search page search.php?query=$1
4) redirecting /cars to browse.php?#tabs-all
5) redirecting compare/*/ (any amount up to 3 times) to compare.php?car[]=X1&car[]=X2&car=X3
well as far is this its working. but i cannt get goal number 3/4 to work cause if i do they just screw the rest :(.
can some one point me out how to write a nice clean .htaccess mod-rewrite please 🙂
Something like this for #3/4?
You should be able to add that at the end. Note that the
#tabs-allisn’t going to translate as a rewrite, since it’s something the browser handles on the client side and nothing the server can do. You could maybe add some javascript to automatically get the browser to go to #tabs-all with some javascript in browse.php.I don’t know if there’s a cleaner way to do #5 besides the 3 “compare” rules, and #1 and #2 are fine. If you rename (or symlink) “search.php” to “new.php”, you could combine those 2 rules to:
but I think it’s better to distinctly rule out /new/cars/ and /used/cars/, since that rule would also rewrite “/qwerty/cars/” to “qwerty.php?…”