Posts

Showing posts from September, 2011

jquery - How Do I Turn HTML Text into a Javascript Variable While Removing Line Breaks? -

i have raw feed of text within body tag of html page. need run function on turn javascript string variable. however, there literal line breaks in html page (which not permissible in js strings). here's example of source of page i'm working with: <html> <head></head> <body> bldg||0|eor| plnc||0|eor| subd|pine manor|1|eor| city|fort myers|1|eor| </body> jquery permissible. how turn javascript variable while removing literal line breaks variables work? var str = document.body.innerhtml.replace(/(\r\n|\n|\r)/gm,"");

javascript - Why is this twitter bootstrap modal not working when using knockout js? -

i trying knockout js working twitter bootstrap modal dialog. i have taken contacts editor example knockout js website , altered use modal dialog add/edit. i have spent quite while trying make work reason not. you can view here: http://jsfiddle.net/27pscgnk/5/ thanks in advance solutions i think problem may in here (this not getting called when user clicks save): self.addcontact = function() { self.contacts.push({ firstname: "", lastname: "", phones: ko.observablearray() }); }; i removed of errors in fiddle , changed add function work based on input, @ fiddle http://jsfiddle.net/27pscgnk/6/ self.contact = { firstname: ko.observable(), lastname: ko.observable(), } self.addcontact = function() { self.contacts.push({ firstname: self.contact.firstname(), lastname: self.contact.lastname(), phones: ko.observablearray() }); }; and in binding: <div class="form-gr

c# - Passing parameters on button click in strongly-typed view to another controller -

i have strongly-typed view (bound usercontroller) lists user particular roles , below have dropdownlist containing roles submit button. need assign new role user. actionresult method in userrolescontroller. how can pass userid , roleid on button click actionresult method. actionresult method in userrolescontroller: [httppost] [validateantiforgerytoken] public actionresult addrole(userrole userrole, int roleid, int userid) { if (!modelstate.isvalid) return view(userrole); var check = db.userroles.any(x => x.roleid == roleid && x.userid == userid); if (check) viewbag.resultmessage = "this user has role specified !"; else db.userroles.add(userrole); db.savechanges(); viewbag.resultmessage = "user added role succesfully !"; return redirecttoaction("index"); } view this: @model ienumerable<mvcappcrud.user> @{ viewbag.title = "assignrole&qu

java - Where is -> oss.sonatype.org/content/repositories/comgoogleappengine-1004 -

i downloaded google app engine "hello world" app , pom.xml file trying download sonatype , fails: [error] plugin org.apache.maven.plugins:maven-compiler-plugin:2.5.1 or 1 of dependencies not resolved: fa iled read artifact descriptor org.apache.maven.plugins:maven-compiler-plugin:jar:2.5.1: not transfer artifa ct org.apache.maven.plugins:maven-compiler-plugin:pom:2.5.1 from/to google-staging (**https://oss.sonatype.org/content/repositories/comgoogleappengine-1004/**): oss.sonatype.org: unknown host oss.sonatype.org -> [help 1] when browse comgoogleappengine, it's not there - "comgooglecodemp4parser-1048/" , "comgooglecodemp4parser-1049/" show up. what doing wrong? answering own question in case helps in future... looks proxy issue got off our work network onto private 1 , things worked/downloaded. interesting thing though "oss.sonatype.org/content/repositories/comgoogleappengine-1004/" still doesn't seem there. t

Problems with a query mysql -

i have 3 tables table name 1: chair fields table 1: id (int) - model (varchar) // primary index: id table name 2: color fields table 2: id (int) - color (varchar) // primary index: id table name 3: chair2color fields table 3: id_chair(int) - id_color(int) // primary index: id_chair-id_color every chair can have different colors: red or green or (red , green). some values table 1 (chair): 1 - modela 2 - modelb 3 - modelc some values table 2 (color): 1 - red 2 - green some values table 3 (chair2color): 1 - 1 2 - 2 3 - 1 3 - 2 i want chairs models order color in way: select chair.id id_chair chair left join chair2color on chair.id=chair2color.id_chair order field (chair2color.id_color,'1','2') the result is: id_chair 1 2 3 my problem chairs red appear in first place (it's ok). then, have chairs green , chairs green , red. i green , red chairs appear before green chairs since red too. my desired result (and think correct one) be:

actionscript 3 - flex4 - NetStream.soundtransform.volume doesn't change -

i have problem receive netstream sound volume changing <![cdata[ import mx.events.flexevent; import flash.events.event; import flash.events.mouseevent; import flash.events.netstatusevent; import flash.media.camera; import flash.media.microphone; import flash.media.video; import flash.net.netconnection; import flash.net.netstream; import flash.media.soundtransform; private const server:string = 'rtmfp://p2p.rtmfp.net/'; private const devkey:string = 'my dev key'; private const reg:string = 'scripts/reg.php'; private const getid:string = 'scripts/getid.php'; private var netconnection:netconnection; private var netstreampublish:netstream; private var streamrcv:netstream; private var videorcv:video; private var peerid:string; private var newvolume:number = 0; private function connect():void

c - Valgrind detects memory leak despite the fact memory has been freed -

i have file "a", 2000 characters, char "a" only, no spaces. then have code, runs trough loop, add buffer, reallocs if limit reached , on errors frees strbuffer variable. #include <stdlib.h> #include <stdio.h> #include <string.h> int main() { int maxs = 200; int numericexpression; int strlength; char *strbuffer; strbuffer = malloc(sizeof(char)*maxs+1); if(strbuffer == null) { printf("failed allocate requested memory!\n"); free(strbuffer); strlength = sizeof(strbuffer); printf("freed %d bytes of memory!\n", strlength); exit(99); } else { numericexpression = sizeof(char)*maxs+1; printf("alocated: %d bytes of memory.\n", numericexpression); } // while simulation int fcv = -1; int numex; // file opening simulation file* fd = fopen("a&q

javascript - Force one way binding while assigning variable to another variable -

i'm trying assign variable variable , try 1 way binding. when value updated in view, updates original variable too. how stop 2 way binding while assigning variable another. for example: function personcontroller ($scope) { var templatevalue= "original value"; $scope.myval= templatevalue; } in view: <input type="text" ng-model="myval" /> result: when type in textbox, updates value in myval , templatevalue too, i.e value in templatevalue changes whatever typed in input box. there way assign variable variable doing 1 way binding? want 2 way binding between $scope.myval , input box not between templatevalue , input box. you can't "force one-way binding" because of weay javascript works. in example, updating myval not update templatevalue . function personcontroller($scope) { var templatevalue = "original value"; $scope.myval = templatevalue; } if have following structure, y

c - Loop with simple counter malfunctioning? -

i have program takes char array , calls function convert. function determines whether character letter or number. program supposed output first letter finds in string. , first numbers finds in string. loop stop looking letters after finds 1 isn't working. any thoughts? code written in c using borland compiler. #include <stdio.h> #include <math.h> #include <stdlib.h> #include <ctype.h> #include <string.h> int convert (char array[],char **); int main() { int intval; char array[512], *charptr; printf("input string starts series of decimal digits:\n>"); while ( gets( array ) != null ){ intval = convert(array, &charptr ); printf ("intval contains %d, charptr contains '%s'\n", intval, charptr); } system("pause"); return 0; } int convert (char array[],char ** charptr) { int i, x, c = 0; char b[512]; (i=0;i<strlen(array);i++){ if (isa

Spring sftp file polling in specific time -

how configure spring sftp:inbound-channel-adapter run between specific timing lets 8am-7pm. have below configuration , need poll between 8am-7pm <int:poller fixed-rate="300000" max-messages-per-poll="1" /> .heard spring batch help. suggestions ? please, more specific. describe requirements in human words. e.g. need poll every 5 min starting 8am , ending on 7pm every day. in case cron like: 0 0/5 8-19 * *

java - is res-type required for JNDI setup in web.xml? -

i met situation jndi provider on different application servers might have different proxy interface/class(like in jms, websphere may have javax.jms.queueconnectionfactory instead of javax.jms.connectionfactory ), in web.xml <resource-ref> <description>jndi jms access</description> <res-ref-name>jms/connectionfactory</res-ref-name> <res-type>javax.jms.queueconnectionfactory</res-type> <res-auth>container</res-auth> </resource-ref> is <res-type>javax.sql.datasource</res-type> must defined make works? i think jndi name should fine should unique in initial context? i find something oracle not sure official? from ee platform spec (emphasis mine): the res-type element optional if injection target specified for resource ; in case res-type defaults type of injection target. i believe javax.jms.connectionfactory should work on websphere application server if other applic

How to execute Javascript after Rails' remote form `disable_with` functionality has completed? -

i using disable_with , , cannot button text change persist (because being overwritten disable_with functionality). remove , data: { disable_with: '...' buttons updated expected. is there way perform actions after disable_with functionality has completed? form: <%= form_for @user, html: {id: 'follow-form'}, remote: true |f| %> <%= button_tag id: 'follow-btn', data: { disable_with: '...' } %> follow <% end %> <% end %> js: $('#follow-form').on('ajax:success',function(data, status, xhr){ if (status.action == 'follow') { $('#follow-btn').text('unfollow'); } else { $('#follow-btn').text('follow'); } } maybe without disable_with and: $('#follow-form').on('ajax:send',function(data, status, xhr){ $('#follow-btn').text('please wait...').attr({disabled: true}); }); and when aj

eclipse - File not found exception - Java -

this question has answer here: java.io.filenotfoundexception, file not being found 4 answers i writing code parallel arrays , when read in data , try display error comes up. ga teaches lab not see problem code , said should try here. here code , error right after it. using eclipse. import java.util.scanner; import java.io.file; import java.io.filenotfoundexception; public class parallelarrays { public static void main(string[] args) throws filenotfoundexception { file citypopulation = new file("citypopulationdata.txt"); scanner filereader = new scanner(citypopulation); filereader.usedelimiter("[\t|\n]+"); string[] cities = new string[400]; int[] pop2010 = new int[400]; int[] pop2013 = new int[400]; double[] area = new double[400]; int count = getdata(filereader, cities, pop2010

colors - Grayscale image and L*a*b space in MATLAB -

i have bunch of images, vast majority of color (rgb) images. need apply spatial features in 3 different channels of lab color space. conversion rgb color space lab color space straightforward through rgb2gray . however, naturally fails when image grayscale (consists of 1 channel only, numerical representation being double , uint8 , really). i familiar fact "luminance" (l) channel of lab color space grayscaled original rgb image. question, however, of different nature; i'm asking is: given image grayscale, trivially l channel in lab color space. what should , b channels be ? should zero? following example, using pre-build "peppers" image, shows visual effect of doing so: i = imread('peppers.png'); figure; imshow(i, []); lab = rgb2gray(i); lab(:, :, 2) = 0; lab(:, :, 3) = 0; figure; imshow(lab, []); if run code, note second imshow outputs reddish version of first image, resembling old dark room. admit not being knowledgeable , b color channels r

c# - ReverseGeocodeQuery does not return correct information -

i created class reverse geocode. public static class reversegeocoding { public static observablecollection<string> addresses = new observablecollection<string>(); public static string address; public static task<mapaddress> doreversegeocodingasync( geocoordinate location ) { mapaddress mapaddress = null; var reversegeocode = new reversegeocodequery { geocoordinate = new geocoordinate( location.latitude, location.longitude ) }; var tcs = new taskcompletionsource<mapaddress>(); eventhandler<querycompletedeventargs<system.collections.generic.ilist<maplocation>>> handler = null; handler = ( sender, args ) => { if ( args.error != null ) { tcs.setexception( args.e

r - How to apply a function over two series of sequentially labelled variables without using column numbers? -

i need apply function using 2 sets of sequentially labelled variables , attach new set of variables data frame. need without referring column numbers in code. more specifically, here simple task trying do: dat <- data.frame(sec1 = sample(c(0:3),10,replace=t) , sec2 = sample(c(0:4),replace=t) , sec3 = sample(c(0:4),replace=t),pri1 = sample(c(0:3),10,replace=t) , pri2 = sample(c(0:4),replace=t) , pri3 = sample(c(0:4),replace=t) ) dat$rel1 <- ifelse(dat$pri1>0,dat$sec1/dat$pri1,na) dat i want repeat "ifelse" function shown above without typing repeatedly each set of variables. i must say, asked similar questions , received helpful answers ( eg1 , eg2 ) in case responses either used column number in code, or example on single set of sequentially labelled variable. not manage revise suggested code solve particular problem. any suggestion appreciated. dat_n <- cbind(dat, mapply(function(x, y) ifelse(y>0,x/y,na) ,dat[grepl("sec",names

How to find index of tuple in list of tuples in Python? -

i have list of tuples in python, a = [('foo', 3), ('bar', 1)] and want modify second element in tuple containing 'foo' . more specifically, increment number. in other terms, want do >>> increment(a, 'foo') >>> print [('foo', 4), ('bar', 1)] you can't directly change value within tuple (tuples immutable). however, can replace element new tuple looks old one: def increment(a, name): i, x in enumerate(a): if x[0] == name: a[i] = (x[0], x[1] + 1) break

c# - Running an exe from Windows Service in Windows Server 2008 R2? -

i trying automate(not fully, part of) website using watin library in c#. followed different strategies , applications has own limitations. , far haven't found complete solution yet. have gone through threads related these approaches on stackoverflow, msdn , codeproject. my application needs running on windows server 2008 r2 , ie10(if matters watin). i developed following applications. 1-windows service : developed windows service , installed on development machine(win7) , worked fine. communicated watin ie. no problem didn't work on server 2008 r2. solve problem, moved in windows application(exe) , tried run windows service. , didn't help. 2-system tray application: developed ui less system tray application , installed on win7 , windows server 2008 r2 using remote desktop. worked. when logged out server. tray application exits itself. because there no session available run it. 3- webservice: developed web service run exe(tray application). , windows service

c# - Multiple AttributeTargets in AttributeUsage -

[attributeusage(attributetargets.property)] public class myattribute : attribute { ... } i want custom attribute used both on properties , fileds not others. how assign multiple targets( attributetargets.property , attributetargets.field )? or it's not possible? and attributetargets.all not want. you can specify multiple targets this, using | (bitwise or) operator specify multiple enum values: [attributeusage(attributetargets.property | attributetargets.field)] public class myattribute : attribute { ... } the bitwise or operator works attributetargets enum because values assigned particular way , it's marked flags attribute. if care to, can read more here: c# fundamentals: combining enum values bit-flags understand how bitwise operators work (c# , vb.net examples)

Form Submission/POST using Requests in Python -

This summary is not available. Please click here to view the post.

asp.net web api - Mutiple Routes in DNN Service Route Mapper not working -

i starting dnn , trying setup controller , service routes reason not working guess may missing or have wrong understanding in how works i have controller 2 actions public class name : dnnapicontroller{ public getapple(string id){ } public getorange(string id){ } } i have created service routes public class routemapper : iserviceroutemapper { public void registerroutes(imaproute maproutemanager) { maproutemanager.maphttproute("name", "apple1", "{controller}/{action}/{id}", new[] {"myservices"}); maproutemanager.maphttproute("name", "orange2", "{controller}/{action}/{id}", new[] {"myservices"}); } } when run 1 of action resolved , 400 other one... any suggestions? why? try declaring routes in follwoing way routemanager.maphttproute("modulename", "apple1", "{controller}/{action}/{id}", new string[] { "yournamesp

c++ - 2d collision detection issue -

i'm working on basic square-square collision detection system checks player , bunch of tiles. problem since works going through tiles starting top left tile (in stage) bottom right tile checks collisions tiles above , left of player before else. because of this, if you're moving left , against wall, stuck because corrects players y position tile above before x position tile left (or right). wondering how can go fixing this. collision code follows: for(std::vector<tile*>::iterator tile = tiles.begin(); tile != tiles.end(); tile++) { if((*tile)->tiletype == tile::tile_wall) { float cx = character->getposition().x; float cy = character->getposition().y; float chw = character->halfwidth(); float chh = character->halfheight(); float thw = tile::tile_width/2; float thh = tile::tile_height/2; float dx = cx - ((*tile)->getposition().x); float dy = cy - ((*tile)->getposition().y);

javascript - Unknown Error on Safari history Navigation using Protractor -webdrivers -

i'm trying test history , buttons using muliple browsers test , error gets thrown: unknownerror: yikes! safari history navigation not work. can go forward or back, once do, can no longer communicate page... (warning: server did not provide stacktrace information) command duration or timeout: 19 milliseconds build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03' system info: host: 'sfm1skf1g3l.local', ip: '10.16.100.172', os.name: 'mac os x', os.arch: 'x86_64', os.version: '10.9.3', java.version: '1.8.0_05' driver info: org.openqa.selenium.safari.safaridriver capabilities [{browsername=safari, takesscreenshot=true, javascriptenabled=true, version=7.0.3, cssselectorsenabled=true, platform=mac, securessl=true}] session id: null this test works in chrome , firefox not safari: it("should open find clinic page", function(){ browser.driver.sleep(2000); br

Using Latex under OS Yosemite -

i started on learning latex world tutorial: . when try call xdvi first.dvi i following message: dyld: library not loaded: /usr/x11/lib/libxaw.7.dylib referenced from: /usr/texbin/xdvi-xaw reason: image not found trace/bpt trap: 5 i tried re-install imagemagick (in case problem caused it), didn't solve case. any guess? sudo ln -s /opt/x11 /usr/x11 worked me. solved problem , i've been trying figure out quite while.

jquery - Timing in JavaScript: Finding a way to make setInterval alternate time -

i building web page class project, , specifically, "about us" page iterates through pictures , descriptions of team members. on view, have this: setinterval(function() { $("#about-img").attr('src', img_src[i]); $("#name").html(names[i]); $("#description").html(descriptions[i]); = (i + 1) % img_src.length; }, 8000); this iterates, however, descriptions longer others. there way wait longer, longer description is? simple be waits(descriptions[i].length * 50); right in setinterval function, javascript has no way of doing that. can do? settimeout asynchronous, , cannot influence second parameter of setinterval scope of first. use settimeout instead of interval function changemessage () { $("#about-img").attr('src', img_src[i]); $("#name").html(names[i]); $("#description").html(descriptions[i]); = (i + 1) % img_src.length; window.settimeout(changemessage, d

c# - How to show messagebox one time only before closing window -

i have made standalone application engineering analyses research purpose. made show graph displaying results in window (i don't know right word it. let me call subwindow) linked main window. remind end users save input files before closing main window, added code behind notification shown below: private void window_closing(object sender, canceleventargs e) { messageboxresult result = messagebox.show("please sure input & output files saved. want close program?", "confirmation", messageboxbutton.yesno, messageboximage.warning); if (result == messageboxresult.yes) { application.current.shutdown(); } else { e.cancel = true; } } xaml code is: <window x:class="gmgen.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" icon="icon1.i

jquery - How to sum two input fields -

i have following layout in html table: <table> <tr><td>id</td><td>item name</td><td>value</td></tr> <tr><td>1</td><td>shampoo</td><td>200</td></tr> <tr><td>2</td><td>soap</td><td>20</td></tr> <tr><td>3</td><td>toothpaste</td><td>8</td></tr> <tr><td></td><td>others</td><td><input class="ta" type="text" value="" /></td></tr> <tr><td></td><td>total</td><td><input id="tp" type="text" value="228" /></td></tr> </table> data of table rows fetched mysql database except 5th row (item:others). while page loads, value of "total" fetched mysql database. if user put value "others" row, everytime value of &

android - How can I get view from ListView by position and set text to item? -

i trying implement custom list. there textview in each row, want set text textview oncreate in following way nullpointer exception. my custom list public class customlist extends arrayadapter<string>{ private final activity context; private final string[] web; private final integer[] imageid; textview txttitle; public customlist(activity context, string[] web, integer[] imageid) { super(context, r.layout.list_single, web); this.context = context; this.web = web; this.imageid = imageid; } @override public view getview(int position, view view, viewgroup parent) { layoutinflater inflater = context.getlayoutinflater(); view rowview= inflater.inflate(r.layout.list_single, null, true); imageview imageview = (imageview) rowview.findviewbyid(r.id.img); txttitle = (textview) rowview.findviewbyid(r.id.txt); txttitle.settext(web[position]); txttitle.settext("menjar ali"); imageview.setimageresource(imageid[position]); return rowview; } } my main activity:

css - Links within tumblr posts not the custom link color in HTML -

i'm using feather 2.0 theme eric hu , i'm having trouble link colors within theme. the code link follows <meta name="color:links" content="#529ecc"/> <meta name="color:links hover" content="#97c5e0"/> but links appear within text posts (or in photo descriptions, etc) show hideous blue- #0000ee. idea why link category isn't applying these particular links? (basically copying , pasting looks relevant links, i'm sorry, have no clue is) css: ::-moz-selection { background: {color:links}; color: #fff; text-shadow: none; } ::selection { background: {color:links}; color: #fff; text-shadow: none; } header .links a, header .links a:link, header .links a:visited, header .description a, header .description a:link, header .description a:visited, .post p a, .post p a:link, .post p a:visited, #pagination a, #pageination a:link, #pagination a:visited, ol.notes li a, ol.notes li a:link, ol.notes li a:visited, .quest

java - JTable removing row gives ArrayOutofBounds exception : 2>=2 -

public static void main(string[] args) { // todo auto-generated method stub object[][] tdata ={new object[]{"1","b","e","f"},new object[]{"2","*","3","4"},new object[]{"3","@","#","$"}}; object[] tname = {"#1","#2","#3","#4"}; defaulttablemodel dtm = new defaulttablemodel(); dtm.setdatavector(tdata, tname); jtable jta = new jtable(dtm); jta.setrowselectionallowed(false); jta.getcolumnmodel().getcolumn(0).setcelleditor(new mbuttoneditor()); jframe jfr = new jframe(); jfr.setsize(800, 800); jfr.setlayout(new flowlayout()); jfr.add(new jscrollpane(jta)); jfr.setdefaultcloseoperation(jframe.exit_on_close); jfr.setvisible(true); } class mbuttoneditor extends defaultcelleditor{ private int cur_row;

mysql - Find the routes involving two buses that can go from A to B -

Image
question in sql sqlzoo: find routes involving 2 buses can go craiglockhart sighthill. show bus no. , company first bus, name of stop transfer, , bus no. , company second bus. this code found, won't work: select distinct a.num, a.company, trans1.name , c.num, c.company route join route b on (a.company = b.company , a.num = b.num) join ( route c join route d on (c.company = d.company , c.num= d.num)) join stops start on (a.stop = start.id) join stops trans1 on (b.stop = trans1.id) join stops trans2 on (c.stop = trans2.id) join stops end on (d.stop = end.id) start.name = 'craiglockhart' , end.name = 'sighthill' , trans1.name = trans2.name order a.num asc , trans1.name when have big problems that, best practice partition it. technically, buses departs craiglockhart should reach sighthill enough transfers, we'll restrict ourselves 1 transfer (because that's how problem's worded). so basically, need f

either crystal reports registry key permissions are insufficient in vb.net -

i find difficult solve problem. i using crystal report in vb.net 2008 , if loaded , run crystal report in form, got error - "either crystal reports registry key permissions insufficient in vb.net " . using windows 7 os. if transfer other pc xp os, there no error occurs. does know this? suggestion? did compile application in x86, x64 or cpu? see if works compile x86 only. same goes installer you're creating. i remember having issue x64 systems , our installer few years back. installer installed x64 version of cr files on client machines , there application failed.

excel - how to make a cell populate data from another sheet based on dropdown selection -

i've looked , didn't example works situation. i making pricing calculator , need have pricing populate in cells once i've selected device dropdown. i've created source data in sheet2 column device column b msrp , column c discounted price on sheet 1 want select device in cell b4 (already have dropdown created) , have automatically populate msrp in c4 , discounted price in d4. i'm not familiar how use vlookup , iferror , other answers i've seen didn't explain how formulas worked enough me adapt situation. any appreciated, thank you! something like: =iferror(vlookup (b4,'sheet2'!a$1:c$200,2,false)),"-") in c4 in sheet 1 return value column 2 on range a:c in sheet 2 (i.e column b). change 2 3 in d4 value column c in sheet 2. false forces excel match values rather picking first match finds. if can't find value iferror returns -. can change c$200 cover full range of whatever in list in sheet 2.

php - wordpress passing parameter to custom template -

i using wordpress. have created page dealer-profile admin , assigned template it. want pass parameter like site-url/dealer-profile/suv i have added following .htaccess rewriterule ^dealer-profile/([a-za-z0-9_-]+)(|/)$ index.php?pagename=dealer-profile&dealer=$1 [qsa] i have tried following add_rewrite_rule('dealer-profile/([^/]+)', 'index.php?pagename=dealer- profile&dealer=$matches[1]', 'top'); flush_rewrite_rules(false); when requesting site-url/dealer-profile/suv , automatically redirects site-url/dealer-profile please suggest, wrong. now doing following function themeslug_query_vars( $qvars ) { $qvars[] = 'dealer'; return $qvars; } add_filter( 'query_vars', 'themeslug_query_vars' , 10, 1 ); function add_rewrite_rules($arules) { $anewrules = array('dealer-profile/([^/]+)/?$' => 'index.php?pagename=dealer-profile&dealer=$matches[1]'); $arules = $anewrules + $arules;