Help with .htaccess

SpaceshipSpaceship
Watch
Impact
38
This is what I have so far:
Code:
RewriteRule ^listings\/(.+)/(.+)$ listing.php?id=$2&loc=$1&type=detail [L]
RewriteRule ^listings\/(.+)/(.+)/add-review\.html$ listing_add_review.php?id=$2&loc=$1&type=review [L]
I need this to happen:

listings/sandiego/Vendor-Name/ -> listing.php
listings/sandiego/Vendor-Name -> listing.php

listings/sandiego/Vendor-Name/add-review.html -> listing_add_review.php

listings/sandiego/Vendor-Name/send-message-friend.html -> listing_email_friend.php

listings/sandiego/Vendor-Name/send-message.html -> listing_email.php


Also it would be nice for the first link to work with or without the trailing slash:
listings/sandiego/Vendor-Name/
listings/sandiego/Vendor-Name

The problem right now is if I go to
listings/sandiego/Vendor-Name/add-review.html

It sends me to the homepage (It is looking for the wrong ID). Help appreciated thanks guys!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
RewriteRule ^newsarchives/$ /index_news_archives.php [NC,L]
RewriteRule ^newsarchives$ /index_news_archives.php [NC,L]

this is what i use for the / stuff

Code:
listings/sandiego/Vendor-Name/add-review.html -> listing_add_review.php
(going off what you have asked for literlity (spelling))
Code:
^listings/sandeigo/vendor-name/([a-zA-Z0-9]).html$ /listing_add_review.php
[NC,L]
the NC = no case (ie ignore case), and the L means stop processing rules

going to take a guess, you might want something like
Code:
^listings/([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9]+).html$ /listing_add_review.php?state=$1&vendor_name=$2
 
0
•••
To be able to use the trailing slash or not, just add /? to the end of the expression (or ? if you already have the / there).
 
0
•••
doesn't the ? mean a single match, ie it has to be there in that location ?
 
0
•••
0
•••
0
•••
powerspike said:
Code:
RewriteRule ^test([/]?)^ /test.php [L]
that will match "test" and "test/" only

Yes that looks good.

Question: on my first line, why is there a backslash?

^listings\/
 
0
•••
DylanButler said:
Yes that looks good.

Question: on my first line, why is there a backslash?

^listings\/


habbit, \ is an escape character, meaning treat the next character as is, always do it with /'s, have had issues in the past with different reg ex libs and stuff.

better to be safe then sorry
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Live Options
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back