简体   繁体   中英

redirect based on url match

I can't get a certain URL to redirect using mod rewrite. I am getting more basic rewriting happening so this is functioning as far as that goes so there is a problem with my URL.

I tried the string here and it showed the patter works..

http://regexpal.com/

testing the following

   RewriteCond %{HTTP_HOST} ^landed.at/component/jreviews/search-results/criteria:5/query:any/jr_country:sri-lanka/order:rdate$
   RewriteRule (.*) http://landed.at/itworked [L,R=301]

I would like in fact to pull the criteria:5 and jr_country:sri-lanka out to make my variables so my url would become

http://landed.at/tours/sri-lanka - tours if criteria:5 and sri-lanka from the jr_country

I'm getting no where fast with regex and why doesn't my basic search match happen? according to regexpal it should find the condition and do the rewrite?

You have included a full path including slashes, but you are only testing it against the HTTP_HOST which will be just landed.at . Did you mean to use REQUEST_URI ? (That would have to include the http:// also.)

I'd suggest this can probably be done more cleanly with plain old redirects. Don't drag the Swiss Army Chainsaw that is mod_rewrite into the game until you really need it. eg:

Redirect permanent /component/jreviews/search-results/criteria:5/query:any/jr_country:sri-lanka/order:rdate http://landed.at/itworked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM